From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,db5c6b2ef47d4b9e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-20 13:35:18 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!out.nntp.be!propagator-dallas!news-in-dallas.newsfeeds.com!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: Subject: Re: RE: short-circuit control forms Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Wed, 20 Jun 2001 16:35:03 EDT Organization: http://www.newsranger.com Date: Wed, 20 Jun 2001 20:35:03 GMT Xref: archiver1.google.com comp.lang.ada:8939 Date: 2001-06-20T20:35:03+00:00 List-Id: In article , 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