comp.lang.ada
 help / color / mirror / Atom feed
From: pattis@cs.washington.edu (Richard Pattis)
Subject: Re: AND and expression evaluation
Date: 25 May 90 15:16:26 GMT	[thread overview]
Message-ID: <12002@june.cs.washington.edu> (raw)
In-Reply-To: 9005241409.AA10929@ajpo.sei.cmu.edu

I apologize to Norman for quoting out of context; I was confused enough at
the time to not understand the necessary context.  Part of my confusion was
caused by a similar example he gave on page 223, saying Y = 0 OR X/Y = 10
will evaluate both operands (of course, this is before the chapter on
exceptions, so it was a true statement based on what was known up to that
time).  I was certainly hung up on what the compiler must/may do.

 So, if I have this right, the simplest "correct" thing to say is that AND
and OR evaluate their operands fully.  The one exception (excuse me) is when
the only effect of evaluating the "second" operand is to raise a predefined
exception.  So, a compiler may optimize an AND to an AND THEN if one of
its operands is simple enough for the compiler to verify that the only
effect of evaluating that operand is computing a value or raising a
predefined exception (no side effects, no possibility of user defined
exceptions). "Second" here does not mean "right", since any operand may be
evaluated first.

Does that cover it; or are there fleas on fleas?

Rich Pattis

      reply	other threads:[~1990-05-25 15:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-05-24 13:21 AND and expression evaluation "Norman H. Cohen"
1990-05-25 15:16 ` Richard Pattis [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox