Yes, It creates the exact same infinite loop that this code does:<div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">rule "MyRule"<br>
when<br> $p : Person(name = "Yoda")<br> then<br> $p.setAge(300);</span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "> update($p);</span><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "> </span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">end</span><br><div><br></div><div>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.</div>
<div><br></div><div>Best Regards, </div><div><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
<br><br><div class="gmail_quote">On Fri, Apr 8, 2011 at 8:39 AM, Geoffrey De Smet <span dir="ltr"><<a href="mailto:ge0ffrey.spam@gmail.com">ge0ffrey.spam@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Related to the modify expression,<br>
I 've always wondered about this code:<br>
<br>
rule "MyRule"<br>
when<br>
$p : Person(name = "Yoda")<br>
then<br>
modify ($p) {<br>
setAge(300)<br>
}<br>
end<br>
<br>
Doesn't this create an infinite loop? (In my experience it does or at<br>
least it takes a lot longer)<br>
Because the modify ($p) schedules any rule using a Person back on the<br>
agenda to be re-evaluated,<br>
so also that rule, which is evaluated and executed again, modifying $p<br>
again, ... hence the infinite loop?<br>
<br>
--<br>
With kind regards,<br>
Geoffrey De Smet<br>
<br>
<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</blockquote></div><br></div></div>