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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham 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-07 10:20:30 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!headwall.stanford.edu!hub1.nntpserver.com!news-xfer.siscom.net!news2.euro.net!uunet!ash.uu.net!spool0901.news.uu.net!spool0900.news.uu.net!reader0902.news.uu.net!not-for-mail Message-ID: <3C39E726.8000408@mail.com> Date: Mon, 07 Jan 2002 13:21:26 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.7+) Gecko/20010929 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: A case where Ada defaults to unsafe? References: <3C39E62F.3020504@look.ca> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Cache-Post-Path: master.nyc.kbcfp.com!unknown@mosquito.nyc.kbcfp.com X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1010427626 reader2.ash.ops.us.uu.net 520 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:18617 Date: 2002-01-07T13:21:26-05:00 List-Id: FGD wrote: > Any way you look at it, better performance is obtained when > short-circuit and is used only when absolutely necessary. It's only > natural for Ada to "default" to the commutative and. What many of you seem to forget is that the commutative form requires that both operands are evaluated. Of course the compiler can elide by the as-if rule, but not if there is a chance of overflow: if a + b > 3 and x + y < 4 -- case 1 if a + b > 3 and then x + y < 4 -- case 2 In the first case, if there is a chance that evaluating x + y could lead to overflow, the compiler cannot forgo the evaluation even in the case of a + b <= 3, becuase the exception must be generated. So we are not making a simple trade-off between letting the programmer or the compiler choose the order.