====== R/List Logical Operator Precedence (Functions/Subroutines/Programs) ====== ====== ====== ==== Created at 13 MAR 1998 09:51AM ==== Synopsis:  The R/List logical AND operator has a higher precedence than the OR operator.  When in doubt, use parenthesis.     A problem was reported using reduce where the results were incorrect.  The syntax was something like:   ... WITH EQ EQ AND WITH EQ ...   A simpler statement would process correctly:   ... WITH EQ AND WITH EQ ...   The reason is operator precedence.  The first is compiled as:   = OR EQ AND EQ   Which has a precedence of:   ( = ) OR ( EQ AND EQ )   ... since OR is lower than AND in precedence.  This is different from Arev (at least some versions) which would compile it as:   ( = OR EQ ) AND ( EQ )   Since there was no OR in the simpler statement, it processed as expected.   Reducing using the following statement should yield the correct results:   ... ( WITH  EQ EQ ) AND WITH EQ ...   As an example, the first works and the second brings back "junk":   run rlist "LIST SYSREPOS JUSTLEN 50 WITH TYPEID = 'OIEVENT' AND WITH CLASSID = 'CLICK' BY @ID", 1   run rlist "LIST SYSREPOS JUSTLEN 50 WITH TYPEID = 'OIEVENT' = 'OIEVENTEXE' AND WITH CLASSID = 'CLICK' BY @ID", 1   And the corrected version of the second:   run rlist "LIST SYSREPOS JUSTLEN 50 ( WITH TYPEID = 'OIEVENT' = 'OIEVENTEXE' ) AND WITH CLASSID = 'CLICK' BY @ID", 1