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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,99e73f65ea2533b9 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 04 Sep 2008 17:02:51 -0500 From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: and then... (a curiosity) Date: Thu, 04 Sep 2008 23:09:02 +0100 Reply-To: brian@shapes.demon.co.uk Message-ID: References: <18b41828-bda4-4484-8884-ad62ce1c831d@f36g2000hsa.googlegroups.com> <874p53bij6.fsf@willow.rfc1149.net> <94cc1ce3-59d1-41fa-9167-f3b60ddd2835@a1g2000hsb.googlegroups.com> <48bba264$1@news.post.ch> <48bce306$1@news.post.ch> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-YVyYIqPKPFrDjI86NY4H60cJPDiS2G5ptFl48hRf75iuH66hrs223VcUfLM64lWsMqP3cgsYcU+krRe!cHBDhScFIUQ8hba3KlylMvjySX9vltbWzWGwGnhoLrNJPjTZad9hasvIn6koxt/u79jgLH+MMGNt!Gg== X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.39 Xref: g2news1.google.com comp.lang.ada:1930 Date: 2008-09-04T23:09:02+01:00 List-Id: On Wed, 03 Sep 2008 11:56:15 -0400, Robert A Duff wrote: >Brian Drummond writes: >> But it does illustrate that (I) "and then" (short circuit form, order >> guaranteed) and (II) "and" (short circuit permitted, but not guaranteed, >> order not guaranteed) are properly separate operations. >> >> For cases such as the logging example (semantics require both to be >> evaluated) my personal choice would be to explicitly evaluate both, and >> combine their evaluation results, as elsewhere in this thread. >> >> Is my understanding of Ada correct in expecting this is the only way to >> guarantee evaluation of both? ( i.e. Ada handles "and" as (II) above) > >No. Ada guarantees that both arguments of "and" are evaluated. >Of course if the compiler knows that evaluation has no effect, it >doesn't need to generate any code -- that would be the case for >"X > 0", for example. In the process it must give up some opportunities for optimisation (though I suspect, not as many as e.g. mandating the short-circuit form in a particular order). Note: I am not complaining that this is an unreasonable design decision. - Brian