I agree with both your and Wolfgangs comments; however it does sound remarkably like Mark's "Slot Specific" vision.<br><br>Perhaps the same issues apply and hence will no doubt be something for Mark and Edson to sleep on :)<br>
<br><div class="gmail_quote">On 8 April 2011 13:57, 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: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">> Wouldn't it be great(?) and an optimisation that with "true modify"<br>
> (i.e. no longer a remove and insert) that we could only re-evaluate<br>
> rules that contained a pattern on a constraint affected by the update?<br>
<br>
</div>I doubt if that is possible, consider this case with a calculated getter:<br>
<br>
class Person {<br>
private int age;<br>
<br>
public int getAgeInHours() {<br>
return 24 * age;<br>
}<br>
<br>
// getter and setter for int age<br>
<br>
}<br>
<br>
and these rules:<br>
<br>
rule "MyRule1"<br>
<div class="im"> when<br>
$p : Person(name = "Yoda")<br>
then<br>
modify ($p) {<br>
setAge(300);<br>
}<br>
end<br>
</div>rule "MyRule2"<br>
when<br>
$p : Person(ageInHours > 2400)<br>
then<br>
System.out.println("This guy is older than 2400 hours!");<br>
end<br>
<br>
After MyRule1 fires and Yoda's age becomes 300, MyRule2 should fire<br>
because Yoda's older than 2400 hours.<br>
<br>
Next, add eval()'s in the mix for more cases like this.<br>
<br>
Op 08-04-11 14:11, Michael Anstis schreef:<br>
<div class="im">> Wouldn't it be great(?) and an optimisation that with "true modify"<br>
> (i.e. no longer a remove and insert) that we could only re-evaluate<br>
> rules that contained a pattern on a constraint affected by the update?<br>
><br>
> So,<br>
><br>
> rule "MyRule"<br>
> when<br>
> $p : Person(name = "Yoda")<br>
> then<br>
> modify ($p) {<br>
> setAge(300);<br>
> }<br>
> end<br>
><br>
> would not cause "MyRule" to re-evaluate as there's enough information<br>
> 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<br>
> have a good explanation :)<br>
><br>
> Cheers,<br>
><br>
> Mike<br>
><br>
> On 8 April 2011 13:00, Esteban Aliverti <<a href="mailto:esteban.aliverti@gmail.com">esteban.aliverti@gmail.com</a><br>
</div><div class="im">> <mailto:<a href="mailto:esteban.aliverti@gmail.com">esteban.aliverti@gmail.com</a>>> wrote:<br>
><br>
> Yes, It creates the exact same infinite loop that this code does:<br>
><br>
> rule "MyRule"<br>
> when<br>
> $p : Person(name = "Yoda")<br>
> then<br>
> $p.setAge(300);<br>
> update($p);<br>
> end<br>
><br>
> As far as I know, the results are the same. The modify() is a more<br>
> compact way to do a lot of set() invocations and an update().<br>
> Maybe there are also some other advantages of using modify(),<br>
> like optimization for example.<br>
><br>
> Best Regards,<br>
><br>
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>
><br>
> Esteban Aliverti<br>
</div>> - Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a> <<a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a>><br>
<div class="im">> - Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
><br>
><br>
><br>
> On Fri, Apr 8, 2011 at 8:39 AM, Geoffrey De Smet<br>
</div><div class="im">> <<a href="mailto:ge0ffrey.spam@gmail.com">ge0ffrey.spam@gmail.com</a> <mailto:<a href="mailto:ge0ffrey.spam@gmail.com">ge0ffrey.spam@gmail.com</a>>> wrote:<br>
><br>
> 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<br>
> does or at<br>
> least it takes a lot longer)<br>
> Because the modify ($p) schedules any rule using a Person back<br>
> on the<br>
> agenda to be re-evaluated,<br>
> so also that rule, which is evaluated and executed again,<br>
> 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>
</div>> <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a> <mailto:<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>><br>
<div class="im">> <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> rules-dev mailing list<br>
</div>> <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a> <mailto:<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>><br>
<div class="im">> <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
><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>
<br>
</div>--<br>
<div><div></div><div class="h5">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>
</div></div></blockquote></div><br>