home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!olivea!sgigate!sgi!wdl1!wdl39!mab
- From: mab@wdl39.wdl.loral.com (Mark A Biggar)
- Newsgroups: comp.lang.ada
- Subject: Re: Mixing logical operators
- Message-ID: <1993Jan5.231518.17527@wdl.loral.com>
- Date: 5 Jan 93 23:15:18 GMT
- References: <1993Jan5.180216.7426@fcom.cc.utah.edu>
- Sender: news@wdl.loral.com
- Organization: Loral Western Development Labs
- Lines: 29
-
- In article <1993Jan5.180216.7426@fcom.cc.utah.edu> swillden@news.ccutah.edu (Shawn Willden) writes:
- >My copy of the Ada standard (ANSI/MIL-STD-1815A) says in 4.5.4:
- > ...for a sequence of operators of the same precedence level,
- > the operators are associated in textual order from left to
- > right...
- >which indicates to me that
- > if i=5 and j=2 or k=3 then
- > ...
- >should be interpreted as
- > if (i=5 and j=2) or k=3 then
- >but the VAX Ada compiler complains that logical operators cannot be
- >intermixed.
- >Is the VAX compiler wrong? Am I reading the appropriate part of the
- >standard?
-
- No, it is implisit in the LRM that even though "and", "or" and "xor"
- are at the same precedence level they DON'T associate with each other.
- The grammar given in LRM section 4.4 disallows expressions with mixed logical
- operators. Para 4 section 4.5 only states associativity rules of operators at
- precedence levels below that of the logical operators. The previous sentence
- to the one you quoted limits the scope of the paragraph to only subexpressions
- from relations on down and excludes expressions which is where the logical
- operators are found in the grammar. So you must, in any mixed logical
- expression, explisitly use parens to specifiy evaulation order and the VAX
- compler is correct.
-
- --
- Mark Biggar
- mab@wdl1.wdl.loral.com
-