[rules-dev] modify (expr) catch 22

Esteban Aliverti esteban.aliverti at gmail.com
Fri Apr 8 08:00:17 EDT 2011


Yes, It creates the exact same infinite loop that this code does:

rule "MyRule"
  when
    $p : Person(name = "Yoda")
  then
    $p.setAge(300);
    update($p);
end

As far as I know, the results are the same. The modify() is a more compact
way to do a lot of set() invocations and an update(). Maybe there are also
some other advantages of using modify(), like optimization for example.

Best Regards,

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
- Developer @ http://www.plugtree.com
- Blog @ http://ilesteban.wordpress.com


On Fri, Apr 8, 2011 at 8:39 AM, 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20110408/2e898fca/attachment.html 


More information about the rules-dev mailing list