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,25aa3c7e1b59f7b5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-04 10:55:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!logbridge.uoregon.edu!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <3C34BF2C.6030500@mail.com> Subject: Re: A case where Ada defaults to unsafe? Message-ID: <7UmZ7.4154$cD4.7803@www.newsranger.com> 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: Fri, 04 Jan 2002 13:54:59 EST Organization: http://www.newsranger.com Date: Fri, 04 Jan 2002 18:54:59 GMT Xref: archiver1.google.com comp.lang.ada:18554 Date: 2002-01-04T18:54:59+00:00 List-Id: In article , Preben Randhol says... >Does this mean that one cannot know whether both sides will be evaluated >or not? How can the optimiser know whether to use short-circuit or not. >i mean what does it look for? That's what it means. But this is the Ada *83* rationale. I don't know what the rule in Ada 95 ended up being. I'm not too sure what an optimizer would look for, and it would likely be very hardware dependant (which is why its better to leave these things to the optimizer). It could be that for a CPU that doesn't do branch prediction, you'd want to not short-circuit register-based booleans, as the integer unit's AND logic will be way quicker than a series of conditional branches. However, on a CPU that does do branch prediction that may not buy you anything. You might also prefer to put boolean variable evaluations first, and have their result short-circuit any boolean function calls that might be in the expression. A really sexy optimizer might even try to transform boolean expressions using DeMorgan's rule so that all the function calls can be put on the outside together and short-circutited. But again, you'd have to have a compiler vendor tell you if your compiler does this. I understand Gnat does not, and I take it most others don't either. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.