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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM 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 Path: g2news1.google.com!news2.google.com!postnews.google.com!73g2000hsx.googlegroups.com!not-for-mail From: =?ISO-8859-1?Q?Santiago_Urue=F1a?= Newsgroups: comp.lang.ada Subject: Re: and then... (a curiosity) Date: Tue, 2 Sep 2008 15:34:20 -0700 (PDT) Organization: http://groups.google.com Message-ID: <5bca12f5-b6cc-4e7e-b020-ae0264531156@73g2000hsx.googlegroups.com> References: <18b41828-bda4-4484-8884-ad62ce1c831d@f36g2000hsa.googlegroups.com> <57qdnfULQ9tzKCHVnZ2dnUVZ_tHinZ2d@comcast.com> <48bd0003$1@news.post.ch> NNTP-Posting-Host: 81.35.5.246 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1220394860 26694 127.0.0.1 (2 Sep 2008 22:34:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 2 Sep 2008 22:34:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 73g2000hsx.googlegroups.com; posting-host=81.35.5.246; posting-account=Lcd2wAoAAAADW2SqWO5AWY55Q-jjpVWU User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.9.0.1) Gecko/2008072820 Firefox/3.0.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1883 Date: 2008-09-02T15:34:20-07:00 List-Id: > I've noticed that. What is the justification for it? I presume that, bein= g > compiler writers, AdaCore has some specialized knowledge that led them to= make > that choice. > I think that the idea is to always use "and then" / "or else" when there is a function call because maybe thanks to lazy evaluation some of those calls can be avoided. In contrast, the AdaCore style guide suggest using plain "and" / "or" operators when just boolean flags are involved because it is usually faster to evaluate all the variables than using lazy evaluation. Branches and jumps instructions really hurt performance in modern processors, so when just a set of boolean variables must be evaluated it is faster to read all of them instead of generating some branches. When function calls are involved you will have those jump instructions anyway, so it is better to use lazy evaluation to avoid the overhead of the function call. -- Santiago Urue=F1a-Pascual