From: wdl39!mab@ford-wdl1.arpa (Mark A Biggar)
Subject: Re: Mixing logical operators
Date: 5 Jan 93 23:15:18 GMT [thread overview]
Message-ID: <1993Jan5.231518.17527@wdl.loral.com> (raw)
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
next reply other threads:[~1993-01-05 23:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-01-05 23:15 Mark A Biggar [this message]
-- strict thread matches above, loose matches on Subject: below --
1993-01-05 21:08 Mixing logical operators Alex Blakemore
1993-01-05 18:02 agate!dog.ee.lbl.gov!hellgate.utah.edu!fcom.cc.utah.edu!swillden
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox