This is an old discussion. Single binding on "or" is a non-orthogonal special case on the language syntax that was introduced in the early days when we only had "infix" CEs. When we started to support prefix CE, the special case was not updated, and as a result, the single binding works only with infix.
IMO, this syntax promotes bad practices and should be disallowed. Although, some people like it and it is still in there. Just to clarify why I think it promotes bad practice: * When you have the same object type for all the patterns inside an "or" group, you should be using constraint connector ||, not the "or" CE. Using your example: $t : Trigger( fa == 1 || == 2 ) // or any variation of the syntax. This keeps the network smaller and prevents unexpected behavior when the constraints are not mutually exclusive and in some cases people forget that the rule will fire once for each logical branch when using "or". * If the object types are different, then you can't use single binding anyway: $o : ( Cheese() or Wine() ) // this will lead to ClassCastExceptions on the usage of $o. So, I really think that the "single binding or" fulfilled its purpose on Drools 3, when we didn't had all the flexibility in the language we have today. But now, the only thing it achieves is promoting bad practices. Just my 0.02c. []s Edson 2009/3/16 Wolfgang Laun <[email protected]> > As far as I know, this should work: > > package orel; > import orel.Main.Trigger; > rule ror1 > when > $t : (or Trigger(fa == 1) > Trigger(fa == 2)) > then > System.out.println( "fired " + $t.getName() ); > end > > This is what Drools-5.0.0 kbuilder.getErrors().toString() returns: > > [5,11]: [ERR 102] Line 5:11 mismatched input 'Trigger' expecting '(' in > rule ror1 in pattern or[6,14]: [ERR 102] Line 6:14 mismatched input > 'Trigger' expecting ')' in rule ror1[6,30]: [ERR 102] Line 6:30 mismatched > input ')' expecting 'then' in rule ror1 > > Shouldn't toString() insert line ends? As it is, the result is pretty much > useless. > > This works: > rule ror1 > when > (or $t : Trigger(fa == 1) > $t : Trigger(fa == 2)) > then > System.out.println( "fired " + $t.getName() ); > end > > -W > > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > > -- Edson Tirelli JBoss Drools Core Development JBoss, a division of Red Hat @ www.jboss.com
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
