[rules-dev] feature request: undo-then

Geoffrey De Smet ge0ffrey.spam at gmail.com
Thu Feb 19 06:42:52 EST 2009


What would an "else clause" do?
Imagine a rule with matches on 5 different fact sets.
How many times would the else part match?
- none (because it matches at least one)
- a very lot (because it matches on any fact set that isn't that one of 
those 5)

The "undo-then" is another concept:
it matches when a rule that matched before (in a previous fireAllRules), 
now no longer matches.
"undo-then" probably isn't the best name, so better suggestions are 
welcome, but "else" isn't a good name for it as it's not about "not 
matching" but about "no longer matching".


Anyway, I 've been thinking and it wouldn't work for all use cases in 
drools-solver:
rule
   when
     q1 : Queen()
     q2 : Queen()
     eval(q1.getY() - q2.getY() < 10)
   then
     a.add(q1.getY() - q2.getY());
   undo-then
     a.subtract(q1.getY() - q2.getY())
end
The y of a queen changes, so the subtract wouldn't subtract the exact 
same number that was added.
Any way we could work around that, or is there no avoiding insertLogical?

With kind regards,
Geoffrey De Smet

Mark Proctor schreef:
> Greg Barton wrote:
>> --- On Wed, 2/18/09, Geoffrey De Smet <ge0ffrey.spam at gmail.com> wrote:
>>
>>   
>>> The current workarounds [to undo-then] are clunky:
>>> - Writing an negative (opposite) rule isn't efficient:
>>> it means declaring the rule twice effectively. Also the
>>> negative rule is usually using lots of or's and
>>> not's which isn't fast.
>>>     
>>
>> This would be made easier by...drum roll please...the else clause! :)
>>   
> yes we want OPSJ style else statements, edson has an idea on how to do 
> that, just a matter of time :(
>> Now, if there was the else clause plus undo-then/closures you could probably write an entire complex ruleset in one rule.  Might as well just use perl, then. :P 
>>   
> heh, that's true you would have potentially encapsulated 4 possible 
> executions in a single rule.
>>
>>       
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>>   
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev




More information about the rules-dev mailing list