[rules-dev] modify (expr) catch 22

Wolfgang Laun wolfgang.laun at gmail.com
Fri Apr 8 08:30:22 EDT 2011


As all loop-fighting techniques, it won't handle all situations. Apart
from loops over 2 or more rules, you still can write

  $a: Article( $p: price > 1000 )   # slot-specifc on price
then
  modify( $a ){ setPrice( $p - 100 ) }

Also, it'll be interesting to see what this will do:

  $a: Fact()
  $b: Fact( $p: prop == $a.prop )   # slot-specifc on prop
then
  modify( $a ){ setProp( $p+1)  }
  modify( $b ){ setProp( $p+1)  }

And so on...
-W




On 8 April 2011 14:17, Michael Anstis <michael.anstis at gmail.com> wrote:
> OK, answers my question :)
>
> It is on the "to do" list already.
>
> On 8 April 2011 13:11, Mark Proctor <mproctor at codehaus.org> wrote:
>>
>> On 08/04/2011 12:39, Geoffrey De Smet wrote:
>> > Related to the modify expression,
>> > I 've always wondered about this code:
>> >
>> > rule "MyRule"
>> >     when
>> >       $p : Person(name = "Yoda")
>> >     then
>> >       modify ($p) {
>> >         setAge(300)
>> >       }
>> > end
>> >
>> > Doesn't this create an infinite loop? (In my experience it does or at
>> > least it takes a lot longer)
>> > Because the modify ($p) schedules any rule using a Person back on the
>> > agenda to be re-evaluated,
>> > so also that rule, which is evaluated and executed again, modifying $p
>> > again, ... hence the infinite loop?
>> It would, unless you have slot specific - which Jess does. Slot specific
>> is something I really want to add, I think it will resolve a lot of
>> recursion problems and make Drools a lot easier to use. I took the slot
>> specific problem and genericsed it further for "slot listeners". I
>> discussed this here:
>> http://blog.athico.com/2010/07/slot-specific-and-refraction.html. I
>> think Laune added some refinements to this in a mailing list entry
>> somewhere.
>>
>> Mark
>>
>>
>>
>> _______________________________________________
>> 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