<div><br></div>   Yes, but just to clarify: as it is now, we parse semantic blocks of code like RHS as a black box (chunk if you will) and then re-parse that with the appropriate dialect parser (like java). Same for expressions in the rule, that we chunk and delegate to MVEL. That is why, for instance, to write an expression in a pattern in need the ugly ( ):<div>
<br></div><div>Person( age == ( $someAge + 1 ) )</div><div><br></div><div>   That also screws with our error handling capabilities. Example: as of today, in the eclipse editor, if you have a parsing error in the consequence, we show the error in the rule header instead of the proper line in the consequence.</div>
<div><br></div><div>   The changes we are doing in the parser now means that we will be able to parse 100% of the content of the DRL file (no black boxes/chunking anymore) and with that improve error handling, code completion, improve syntax and allow us to do smarter static code analysis. Example of the results as of this morning:</div>
<div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; line-height: 17px; white-space: pre; ">@name4( k1 = &quot;a&quot;, </span></div>
<div><span class="Apple-style-span" style="font-family: &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; line-height: 17px; white-space: pre; ">        formula = Math.max( 10 + 25, 22 ) % 2 + someVariable, </span></div>
<div><span class="Apple-style-span" style="font-family: &#39;Bitstream Vera Sans Mono&#39;, Courier, monospace; font-size: 12px; line-height: 17px; white-space: pre; ">        array = { a, b, c } )</span><br><br></div><div>
   Above example is for annotations, but the same will happen everywhere, including the LHS. See how &quot;formula&quot; uses a free form expression without any kind of clutter/delimiters/etc?</div><div><br></div><div><div class="gmail_quote">
   Edson</div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">2011/1/20 Greg Barton <span dir="ltr">&lt;<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">When you say &quot;owning 100% of the language syntax&quot; does that include the RHS?  Just curious.<br>
<font color="#888888"><br>
GreG<br>
</font><div><div></div><div class="h5"><br>
On Jan 19, 2011, at 22:04, Edson Tirelli &lt;<a href="mailto:ed.tirelli@gmail.com">ed.tirelli@gmail.com</a>&gt; wrote:<br>
<br>
&gt;   As of Drools 5.1.1, drools looks at the expression in &quot;from&quot; as a<br>
&gt; black box. Every time it is executed, drools creates a new fact handle<br>
&gt; to wrap the result(s). Since the lock and no-loop features are based<br>
&gt; on the fact handles, the sometimes undesired interaction occurs. We<br>
&gt; may be able to improve this in drools 6, when we will have the engine<br>
&gt; owning 100% of the language syntax, that will enable us to run better<br>
&gt; expression analisys than we can do today.<br>
&gt;<br>
&gt;   Edson<br>
&gt;<br>
&gt; Em quarta-feira, 19 de janeiro de 2011,<br>
&gt; hyjshanghai&lt;<a href="mailto:hyjshanghai@gmail.com">hyjshanghai@gmail.com</a>&gt; escreveu:<br>
&gt;&gt;<br>
&gt;&gt; You explanation is very reasonable:<br>
&gt;&gt; the engine assumes anything within $p may be changed by modify($p), although<br>
&gt;&gt; $p.address is not changed actually.<br>
&gt;&gt;<br>
&gt;&gt; However, I tried these rules myself and both rules were fired. Why?<br>
&gt;&gt; According to the document, only one of the rules should fire; the other&#39;s<br>
&gt;&gt; activation should be cancelled because the engine assumes $p has changed,<br>
&gt;&gt; which may mismatch the other rule, right?.<br>
&gt;&gt;<br>
&gt;&gt; The following are the output and my rules. The only difference between my<br>
&gt;&gt; rules and the document&#39;s is that my rules don&#39;t belong to any<br>
&gt;&gt; ruleflow-group.<br>
&gt;&gt;<br>
&gt;&gt; ==== Program Output of Inserting a &quot;new Person()&quot; and Firing All Rules.<br>
&gt;&gt; BEGIN====<br>
&gt;&gt; Rule &#39;Apply discount&#39; fired. Person: Person{name[Tom],<br>
&gt;&gt; address[Address{state[NC], city[Raleigh]}], region[null], discount[0.9]}<br>
&gt;&gt; Rule &#39;Assign to sales region 1&#39; fired. Person: Person{name[Tom],<br>
&gt;&gt; address[Address{state[NC], city[Raleigh]}], region[sales region 1],<br>
&gt;&gt; discount[0.9]}<br>
&gt;&gt; ==== Program Output of Inserting a &quot;new Person()&quot; and Firing All Rules.<br>
&gt;&gt; END====<br>
&gt;&gt;<br>
&gt;&gt; ==== The Rules I Tested. BEGIN ====<br>
&gt;&gt; package hello.rules<br>
&gt;&gt; import java.util.*<br>
&gt;&gt; import java.math.*<br>
&gt;&gt; import hello.model.Address;<br>
&gt;&gt; import hello.model.Person;<br>
&gt;&gt;<br>
&gt;&gt; rule &quot;Assign to sales region 1&quot;<br>
&gt;&gt; lock-on-active true<br>
&gt;&gt; when<br>
&gt;&gt;    $p : Person()<br>
&gt;&gt;    $a : Address( state==&quot;NC&quot;) from $p.address<br>
&gt;&gt; then<br>
&gt;&gt;    modify ($p) { setRegion(&quot;sales region 1&quot;) }<br>
&gt;&gt;    System.out.println(&quot;Rule &#39;Assign to sales region 1&#39; fired. Person:<br>
&gt;&gt; &quot;+$p);<br>
&gt;&gt; end<br>
&gt;&gt;<br>
&gt;&gt; rule &quot;Apply discount&quot;<br>
&gt;&gt; lock-on-active true<br>
&gt;&gt; when<br>
&gt;&gt;    $p : Person()<br>
&gt;&gt;    $a : Address( city==&quot;Raleigh&quot;) from $p.address<br>
&gt;&gt; then<br>
&gt;&gt;    modify ($p) { setDiscount((float)0.9) }<br>
&gt;&gt;    System.out.println(&quot;Rule &#39;Apply discount&#39; fired. Person: &quot;+$p);<br>
&gt;&gt; end<br>
&gt;&gt; ==== The Rules I Tested. END ====<br>
&gt;&gt;<br>
&gt;&gt; ==== The Person and Address. BEGIN ====<br>
&gt;&gt; public class Person<br>
&gt;&gt; {<br>
&gt;&gt;    private String name;<br>
&gt;&gt;    private Address address;<br>
&gt;&gt;    private String region;<br>
&gt;&gt;    private float discount;<br>
&gt;&gt;    public String getRegion() {<br>
&gt;&gt;        return region;<br>
&gt;&gt;    }<br>
&gt;&gt;    public void setRegion(String region) {<br>
&gt;&gt;        this.region = region;<br>
&gt;&gt;    }<br>
&gt;&gt;    public float getDiscount() {<br>
&gt;&gt;        return discount;<br>
&gt;&gt;    }<br>
&gt;&gt;    public void setDiscount(float discount) {<br>
&gt;&gt;        this.discount = discount;<br>
&gt;&gt;    }<br>
&gt;&gt;<br>
&gt;&gt;    public String getName() {<br>
&gt;&gt;        return name;<br>
&gt;&gt;    }<br>
&gt;&gt;    public void setName(String name) {<br>
&gt;&gt;        <a href="http://this.name" target="_blank">this.name</a> = name;<br>
&gt;&gt;    }<br>
&gt;&gt;    public Address getAddress() {<br>
&gt;&gt;        return address;<br>
&gt;&gt;    }<br>
&gt;&gt;    public void setAddress(Address address) {<br>
&gt;&gt;        this.address = address;<br>
&gt;&gt;    }<br>
&gt;&gt;    @Override<br>
&gt;&gt;    public String toString()<br>
&gt;&gt;    {<br>
&gt;&gt;        return String.format(&quot;Person{name[%s], address[%s], region[%s],<br>
&gt;&gt; discount[%s]}&quot;,<br>
&gt;&gt;                name, address.toString(), region, discount);<br>
&gt;&gt;    }<br>
&gt;&gt; }<br>
&gt;&gt;<br>
&gt;&gt; public class Address<br>
&gt;&gt; {<br>
&gt;&gt;    private String state;<br>
&gt;&gt;    private String city;<br>
&gt;&gt;    public String getState() {<br>
&gt;&gt;        return state;<br>
&gt;&gt;    }<br>
&gt;&gt;    public void setState(String state) {<br>
&gt;&gt;        this.state = state;<br>
&gt;&gt;    }<br>
&gt;&gt;    public String getCity() {<br>
&gt;&gt;        return city;<br>
&gt;&gt;    }<br>
&gt;&gt;    public void setCity(String city) {<br>
&gt;&gt;        this.city = city;<br>
&gt;&gt;    }<br>
&gt;&gt;<br>
&gt;&gt;    @Override<br>
&gt;&gt;    public String toString()<br>
&gt;&gt;    {<br>
&gt;&gt;        return String.format(&quot;Address{state[%s], city[%s]}&quot;, state, city);<br>
&gt;&gt;    }<br>
&gt;&gt; }<br>
&gt;&gt; ==== The Person and Address END ====<br>
&gt;&gt; --<br>
&gt;&gt; View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Why-Using-from-Always-Return-A-New-Fact-tp2286393p2292029.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Why-Using-from-Always-Return-A-New-Fact-tp2286393p2292029.html</a><br>

&gt;&gt; Sent from the Drools - User mailing list archive at Nabble.com.<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; rules-users mailing list<br>
&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;<br>
&gt;<br>
&gt; --<br>
&gt;  Edson Tirelli<br>
&gt;  JBoss Drools Core Development<br>
&gt;  JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>
</div>