[rules-users] semantically equivalent DROOLS L-value expressions?

Wolfgang Laun wolfgang.laun at gmail.com
Tue Oct 23 00:14:10 EDT 2012


What's the declaration of class Message, especially for the field
_calendar? A leading underscore is not according to the Java Beans
convention.

One rule has '== "foo"' where the other one has '!= "foo"'.

If this were changed, the rules would not be semantically equivalent.
Rewrite R2

rule "R2"
     when
         Message (businessDayConvention != "foo" && _calendar == "bar") ||
         Message (businessDayConvention == "foo")
     then
end

as

rule "R2a"
     when
         Message (businessDayConvention != "foo" && _calendar == "bar")
     then
end
rule "R2b"
     when
         Message (businessDayConvention == "foo")
     then
end

to see the difference - that's how "or" between (!) patterns is
implemented, and so it's not the same as an "or" between constraints
of a single pattern.

-W

On 23/10/2012, Cotton.Ben <ben.d.cotton.iii at gmail.com> wrote:
>
> This still shows R1 as a syntax error in Eclipse .DRL view (Drools 5.2).
> R2
> has no syntax error.  Are R1 and R2 semantically the same?
>
> rule "R1" //XLS Item=7
>     when
>         Message(
>              ((businessDayConvention == "foo" && _calendar == "bar") ||
> _calendar== "foo") //syntax error
>         )
>     then
>         System.out.println( "RULE pattern-matched Message.  DROOLS
> Consequence executing now." );
> end
>
>
> BuildError: Unable to Analyse Expression businessDayConvention == "foo" &&
> _calendar == "bar" ||
>  _calendar == "foo": [Error: no such identifier: _calendar] [Near : {...
> vention == "foo" && _calendar
>  == "bar" || _calenda ....}] ^ [Line: 1, Column: 35]
>
>
>
> rule "R2" //XLS Item=7
>     when
>         Message (businessDayConvention != "foo" && _calendar == "bar") ||
>         Message (businessDayConvention == "foo")
>     then
>         System.out.println( "RULE pattern-matched Message.  DROOLS
> Consequence executing now." );
> end
>
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/semantically-equivalent-DROOLS-L-value-expressions-tp4020423p4020427.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list