Wouldn't it be great(?) and an optimisation that with "true modify" (i.e. no longer a remove and insert) that we could only re-evaluate rules that contained a pattern on a constraint affected by the update?<br>
<br>So,<br><br><span style="font-family: courier new,monospace;">rule "MyRule"</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
when</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
$p : Person(name = "Yoda")</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
then</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
modify ($p) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
setAge(300)</span>;<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
}</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
end</span><br style="font-family: courier new,monospace;"><br>would not cause "MyRule" to re-evaluate as there's enough information present to ascertain that the modify does not alter the match.<br><br>Tell me Wolfgang, why this is such a bad idea - I just know you'll have a good explanation :)<br>
<br>Cheers,<br><br>Mike<br><br><div class="gmail_quote">On 8 April 2011 13:00, Esteban Aliverti <span dir="ltr"><<a href="mailto:esteban.aliverti@gmail.com">esteban.aliverti@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Yes, It creates the exact same infinite loop that this code does:<div><br></div><div><span style="border-collapse: collapse; font-family: arial,sans-serif; font-size: 13px;"><div class="im">rule "MyRule"<br>
when<br> $p : Person(name = "Yoda")<br> then<br></div> $p.setAge(300);</span></div><div><span style="border-collapse: collapse; font-family: arial,sans-serif; font-size: 13px;"> update($p);</span><span style="border-collapse: collapse; font-family: arial,sans-serif; font-size: 13px;"> </span></div>
<div><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><font color="#888888"><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></font><div><div></div><div class="h5"><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" target="_blank">ge0ffrey.spam@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); 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" target="_blank">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></div></div>
<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>
<br></blockquote></div><br>