From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 5 Jan 93 23:15:18 GMT From: wdl39!mab@ford-wdl1.arpa (Mark A Biggar) Subject: Re: Mixing logical operators Message-ID: <1993Jan5.231518.17527@wdl.loral.com> List-Id: In article <1993Jan5.180216.7426@fcom.cc.utah.edu> swillden@news.ccutah.edu (Sh awn 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