<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi All,<br>
<br>
Just wanted to share with you an easy mistake. This is done running
Drools 5.5.0.Final.<br>
<br>
Imagine a fact<br>
<br>
<code>Cheese (</code><code><br>
</code><code> creationTick : double</code><code><br>
</code><code> preservationTicks : double</code><code><br>
</code><code>)</code><br>
<br>
Then the following does not do what you expect:<br>
<br>
<code>rule "dump old cheese"</code><code><br>
</code><code> when</code><code><br>
</code><code> $c : Cheese( $sbd : creationTick +
preservationTicks )</code><code><br>
</code><code> CurrentTime( tick >= $sbd )</code><code><br>
</code><code> then</code><code><br>
</code><code> System.out.println("</code><code>we have to
dump "+$c);</code><code><br>
</code><code>end</code><br>
<br>
You would expect that $c is dumped when current time has passed
creationTick + preservationTicks. But no. The variable $sbd is bound
to creationTick <i>before</i> the preservationTicks are added!! I
must say that I do not quite understand how ($sbd : creationTick) +
preservationTicks resolves to "true" to make the premise succeed...
Maybe because it is != 0?<br>
<br>
I found that it should be:<br>
<br>
<code>rule "dump old cheese"</code><code><br>
</code><code>
when</code><code><br>
</code><code>
$c : Cheese( $sbd : (creationTick + preservationTicks) )</code><code><br>
</code><code>
CurrentTime( tick >= $sbd )</code><code><br>
</code><code>
then</code><code><br>
</code><code>
System.out.println("we have to dump "+$c);</code><code><br>
</code><code>
end</code><br>
<br>
This makes sense. Now $sbd is bound to the result of the addition.
But it is an easy trap!!<br>
<br>
Regards,<br>
Willem<br>
</body>
</html>