[rules-dev] modify (expr) catch 22

Wolfgang Laun wolfgang.laun at gmail.com
Fri Apr 8 07:53:27 EDT 2011


Reevaluating after change is the whole idea of a production rule system.

And you have to guard against it to avoid infinity.
  age == null
  age == 0
or use
  no-loop true

-W


On 8 April 2011 13:39, Geoffrey De Smet <ge0ffrey.spam at gmail.com> 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?
>
> --
> With kind regards,
> Geoffrey De Smet
>
>
> _______________________________________________
> 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