<br><br><div class="gmail_quote">On 4 January 2011 11:15, Gabor Szokoli <span dir="ltr"><<a href="mailto:szocske@gmail.com">szocske@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
Purely for educational purposes I am trying to figure out how this<br>
will work when multiple Sale instances share the same "type" string.<br>
<br>
It seems to me that under the default "identity" assertion mode of the<br>
Working Memory, as many SaleType instances would be maintained as<br>
there are unexpired Sale events. In the degenerate case of all n Sale<br>
instances sharing the same type string, rules that bind a SaleType<br>
variable on their LHS should fire n times more than expected.<br></blockquote><div><br>This is n - 1 times :-)<br> <br>The fix is simple:<br><br>when<br>
Sale( $type : type )<br> not SaleType( type == $type )<br>then<br>
insertLogical( new SaleType( $type ) );<br><br>-W<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Am I missing something?<br>
<br>
On the other hand "declare" creates a constructor with parameters? Neat!<br>
<br>
On Mon, Jan 3, 2011 at 4:28 PM, Edson Tirelli <<a href="mailto:ed.tirelli@gmail.com">ed.tirelli@gmail.com</a>> wrote:<br>
><br>
> declare SaleType<br>
> type : String<br>
> end<br>
><br>
> rule "register types"<br>
> when<br>
> Sale( $type : type )<br>
> then<br>
> insertLogical( new SaleType( $type ) );<br>
> end<br>
><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>
</blockquote></div><br>