[rules-users] Scope of bindings, identical patterns
Chris Woodrow
woodrow.chris at gmail.com
Fri Oct 26 11:06:37 EDT 2007
Yes, a single fact will match multiple patterns but you can avoid it (As far
as I remember, it was not the case in v3 and earlier).
You can either specify this in your Java :
RuleBaseConfiguration conf = new RuleBaseConfiguration();
conf.setRemoveIdentities( true );
RuleBase rulebase = new ReteooRuleBase( conf );
Or in your rule :
rule "foo"
when
$a : Cheese(name="Stilton")
$b : Cheese(this != $a, name="Stilton")
then
# etc
end
Chris
2007/10/26, Julian Morrison < jmorrison at i-neda.com>:
>
> Suppose I have a rule like:
>
> rule "foo"
> when
> $a : Cheese(name="Stilton")
> $b : Cheese(name="Stilton")
> then
> # etc
> end
>
> First question: is it possible that a == b ? In other words, can both
> patterns end up matching the same object in one activation? I have been
> assuming this is so, but it isn't covered in the docs so far as I can see.
>
> Second question: why can't I add as a pattern, $a != $b ? The eclipse
> IDE compiler complains they are undefined. What is the scope of the
> bindings defined by $a and $b ?
>
> --
> Julian Morrison
> Programmer
> i-neda Ltd.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071026/de28bd87/attachment.html
More information about the rules-users
mailing list