Seems to me that ~is~ operator precedence: We evaluate AND before OR, just as we evaluate * before +. But that's closely related to the distributive rule, right?
P and Q or R R or P and Q ...both evaluate the same way, to "(P and Q) or R". The distributive property says that P and (Q or R) ...evaluates to (P and Q) or (P and R) I'm just as rusty in COBOL as Mr Oppolzer, so I didn't know you could say IF VAR = 'B' OR 'R' But if you can, it must mean "IF VAR = 'B' OR VAR = 'R'". --- Bob Bridges, [email protected], cell 336 382-7313 /* No one would talk much in society if he knew how often he misunderstands others. -Goethe */ -----Original Message----- From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf Of Paul Gilmartin Sent: Friday, June 5, 2020 13:46 Ouch! That's not operator precedence; that's implied Distributive Law. Does COBOL work that way? I hope not. And what about: (SMOD (IND1) = 'B' AND SMOD (IND1) = 'R') as a verbose way of coding FALSE? --- On Fri, 5 Jun 2020 17:31:16 +0000, Seymour J Metz wrote: >I'm pretty sure that the issue is operator precedence. > >(SMOD (IND1) = 'B' OR 'R') means (SMOD (IND1) = 'B' OR SMOD (IND1) = 'R') >________________________________________ >From: Bernd Oppolzer >Sent: Friday, June 5, 2020 1:10 PM > >after 25 years playing with other languages like PL/1, C and ASSEMBLER, >I have now to work with COBOL again. Took me some time to get started, >because my COBOL knowledge was at a, say, 1970s level :-) > >...But today I had a strange experience with the following (not so >complicated) IF condition: > > IF (TVOLL (IND1) NOT = HIGH-VALUE) > AND (SMOD (IND1) = 'B' OR 'R') > >I first coded it without the parantheses and it did not work ... > > IF TVOLL (IND1) NOT = HIGH-VALUE > AND SMOD (IND1) = 'B' OR 'R' > >the first part of the condition was false (TVOLL ... was HIGH-VALUE >indeed), and so I hoped that the combined condition would be false, >although SMOD was R. But: nope. > >This must be a misunderstanding at my part, what the abbreviation ... OR >'R' ... means in this case. Maybe in combination with the AND. > >Could someone please explain the rules or give any hint? Of course, it >is always a good idea to use parantheses, when in doubt. But I really >thought that it would be ok without parantheses in this case ... what >is the problem here, and what are the semantics in the variant without >parantheses? ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
