[rules-users] Scope of bindings, identical patterns

2007-10-26 Thread Julian Morrison
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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Scope of bindings, identical patterns

2007-10-26 Thread Mark Proctor

Julian Morrison wrote:

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.
  

Yes this is no different from
select * from Cheese a, Cheese b

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 ?
  

$a : Cheese(name==stilton)
$b : Cheese( this != $a, name == stilton )

Or you can use an eval:
eval( $a != $b )


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users