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-Thread: 103376,99e73f65ea2533b9 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 01 Sep 2008 22:41:34 -0500 From: "Steve" Newsgroups: comp.lang.ada References: <18b41828-bda4-4484-8884-ad62ce1c831d@f36g2000hsa.googlegroups.com> Subject: Re: and then... (a curiosity) Date: Mon, 1 Sep 2008 20:41:33 -0700 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5512 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Message-ID: <57qdnfULQ9tzKCHVnZ2dnUVZ_tHinZ2d@comcast.com> X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 71.59.220.217 X-Trace: sv3-ardm9HSdQP2hYz8VPXh3pL2SEHQKaBMuTjZ/PZfzfKFtilvCiGXhKJYXAn01GQYc7BEjCIZf3iZjBzx!9KWOtxFXVPhcAQWicwY7mimxJiSHYmsUF58b4ifgaFjDizsbRV/9oNCi//2HPqTncLIamCf0cjyz!65BMhOp53w9o3iUSmeXMwVIg4yWEgw== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net 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:1857 Date: 2008-09-01T20:41:33-07:00 List-Id: "mockturtle" wrote in message news:18b41828-bda4-4484-8884-ad62ce1c831d@f36g2000hsa.googlegroups.com... > Dear.all, > today while I was writing in my favorite language > (PERL with C extensions, of course :-)))) I wondered why in Ada the > "shortcut and" is "and then", while the simple "and" has not > a shortcut behaviour. My curiosity stems from the fact that > I am not able to envision any situation where the "non shortcut" > version would preferable, but I immagine that there was some > reason for this choice. Do anyone have any hint? > > Thank you in advance. There are cases where both arguments to an "and" operator should always be used. For example if you have Function A and Functon B involved in a condition: if A(x) and B(y) then ... do something end if; If short circuit evalution is permitted then more complex logic is required to assure that both arguments are evaluated: resultA := A(x); resultB := B(z); if resultA and resultB then ... do something end if; With Ada you can choose whether or not you want short circuit evaluation. If you require short circuit evaluation you must convey that information to the compiler. If you do not require short circuit evaluation you can convey that information as well. The more the compiler knows about your requirements, the greater the potential for optimization. The form used also conveys information about the code to programmers reading the code. Regards, Steve