[comp.lang.ada] AND and argument evaluation

madmats@elcgl.epfl.ch ("", Mats Weber) (05/29/90)

RFC-822-Headers:
Received: from elcgl.epfl.ch by SIC.Epfl.CH with VMSmail ; Sun, 27 May 90 22:13:25 N
X-ST-Vmsmail-To: gw::"pattis@june.cs.washington.edu"
gw::"info-ada@ajpo.sei.cmu.edu"

==================
 
>Barnes (3rd Ed), top of page 61:
 
>  In the case of AND and OR, both operands are always evaluated but the
>order is not specified.
 
>Cohen, middle of page 490:
 
>  For example, an implementation may choose to optimize the expression
>     B/=0 and A/B > C
>  by evaluating it as if it were written
>     B/= 0 and then A/B > C
 
>I can't find anything in the LRM (maybe I'm not looking in the right 
>spots)
>that nails this down.  In either case, someone's book is wrong.
 
>Does someone know the "truth" about this issue?
 
>Rich Pattis

Barnes is wrong. The LRM allows an implementation to suppress evaluation of 
parts of expressions if these evaluations have no other effect than raising 
a predefined exception.
Thus, in your example, if "/" and ">" denote predefined operators, then 
their evaluation may be suppressed in cases where B/=0 is false.

The difference between "and" and "and then" is that with "and then", the 
right hand side operand MUST NOT be evaluated if the left hand side 
evaluates to false.


Mats Weber
Swiss Federal Institute of Technology
EPFL DI LGL
1015 Lausanne
Switzerland

E-mail : madmats@elcgl.epfl.ch
phone  : +41 21 693 52 92
fax    : +41 21 693 39 09

jamesth@microsoft.UUCP (James THIELE) (05/31/90)

[A very long discussion over many messages extensively quoting the
[Ada LRM and various Ada books with numerous comments on abstract
[conditions where optimization is allowed by compilers deleted.

When I worked with Ada, 1986-9, I remember many times when a
seemingly simple question about Ada syntax or semantics required
a long treasure hunt through the LRM.  The answers were almost
always buried in references to other sections.

Sure, I can now tell you quickly why "for Index in -1..1 loop"
is not valid Ada, but you won't find a comment about "-1..1"
in the section on "for".

Which brings me to my favorite quote about Ada:

	"Ada is PASCAL for lawyers."

Anyone know who said it first?

James Thiele -- microsoft!jamesth