<a id="d0e4493" class="indexterm">Compare these three quotes from the current Expert documentation:<br><br>(1) Return Value restriction (...) must return results that do not
depend on time.<br></a><a id="d0e4551">(2) An </a><a id="d0e4559" class="indexterm">inline eval constraint (...)
expression (...)
expression must be constant over time.<br>(3) </a><a id="d0e4735">[CE] Evals (...) are (...) ideal (...) when functions
return values that change over time.<br><br>Note that this appears to mean that the behaviour of (1) == (2) != (3).<br><br>Many things can or must "change over time:" fact data, global data, results of constructors such as new Date() or methods such as System.currentTimeMillis().<br>
<br>So what can I use in an Eval CE that cannot be used in a Return Value or Inline Eval?<br><br>Perhaps this is trying to convey some notion of caching for constraints and the evaluation strategy for LHS, but then the wording is insufficient. Let's make an experiment.<br>
<br>Example 1:</a><a id="d0e4735"> Given these rules and one pair of facts A, B, which of the three rules ab1, ab2, ab3 will fire after the last rule (a) fires? There are 8 possible answers. (You may notice that there is some redundancy in each rule.)<br>
<br>rule ab1<br>when<br> A( $va:va, $b: b ) eval( $va + $b.getVb() > 100 )<br> B( this == $b, $vb: vb ) eval( $va + $vb > 100 )<br>then<br> System.out.println( "ab1: a+b > 100" ); <br>end<br>
<br>rule ab2<br>when<br> A( $va:va, $b: b , eval( $va + $b.getVb() > 100 ) )<br> B( this == $b, $vb: vb, eval( $va + $vb > 100 ) )<br>then<br> System.out.println( "ab2: a+b > 100" ); <br>end<br>
<br>rule ab3<br>when<br> $a: A( $b: b , $va: va > ( 100 - $b.getVb() ) )<br> B( this == $b, $vb: vb > ( 100 - $a.getVa() ) )<br>then<br> System.out.println( "ab3: a+b > 100" ); <br>end<br>
<br>rule a<br>salience -10<br>no-loop true<br>when<br> $a: A( $va: va ) <br> $b: B( $vb: vb )<br>then<br> modify( $b ){ setVb( 200 ) }<br>end<br><br>Example 2: Now change the first line in the when parts according to:<br>
ab1:<br></a><a id="d0e4735"> A( $va:va, $b: b )<br>ab2:<br> </a><a id="d0e4735">A( $va:va, $b: b )</a><a id="d0e4735"><br>ab3: <br></a><a id="d0e4735"> $a: A( $b: b )</a><a id="d0e4735"><br><br></a><a id="d0e4735">Which of the three rules ab1, ab2, ab3 will fire now after the last rule (a) fires?</a><a id="d0e4735"><br>
<br>Wolfgang<br><br>PS: Scroll down for the answers.<br><br>v<br><br><br>v<br><br><br>v<br><br><br>v<br><br><br>v<br><br><br>v<br><br><br>v<br><br><br>Example 1: None of the rules fires.<br>Example 2: All three rules fire.<br>
<br><br></a>