comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: RE: short-circuit control forms
Date: Wed, 20 Jun 2001 20:35:03 GMT
Date: 2001-06-20T20:35:03+00:00	[thread overview]
Message-ID: <XN7Y6.3051$yp1.99405@www.newsranger.com> (raw)
In-Reply-To: mailman.993066684.13202.comp.lang.ada@ada.eu.org

In article <mailman.993066684.13202.comp.lang.ada@ada.eu.org>, Beard, Frank
says...
>"and then" and "or else".  As soon as one of the conditions is FALSE
>for "and" or TRUE for "or", there is no need to check the remaining
>arguments.

That's assuming the conditional expressions have no side-efects. Questions of
the wisdom of making boolean ops with side effects aside (and much of the Win32
API is implemented this way), it would be a very Bad Thing to go blindly
converting conditionals to the short circuit form in existing Ada code, without
first carefully analyzing the conditions to verify that things will still work
properly if the later condition doesn't get executed. 

I can't find anything in the LRM that says that compilers *can't* optimize away
unneeded conditions in the way you describe (any language lawyers in the
house?), but it wouldn't shock me to find loads of code that assumes it won't
happen. I'm not sure what the LRM's silence on a subject means in this case. But
assuming it means "all bets are off", then it looks to me like compilers are
perfectly free to short-circuit, or even reorder and short-circuit normal
conditional expressions.

--
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



  reply	other threads:[~2001-06-20 20:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-20 19:50 short-circuit control forms Beard, Frank
2001-06-20 20:35 ` Ted Dennison [this message]
2001-06-20 22:32   ` Jeffrey Carter
2001-06-21  1:18     ` Mark Lundquist
2001-06-21 17:05       ` Jeffrey Carter
2001-06-21 14:31     ` Wes Groleau
2001-06-20 23:45   ` Dale Stanbrough
2001-06-20 20:57 ` Marin David Condic
2001-06-21  7:31 ` Keith Thompson
replies disabled

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