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: g2news2.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: Wed, 03 Sep 2008 07:29:30 -0500 From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: and then... (a curiosity) Date: Wed, 03 Sep 2008 13:35:40 +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-r0oqnIDfk+ssBmx5xAVPqxsM8qxnpmbgJ9gvX3jjw+QyUUsmQDIQeW5XtoATUX5EzBmUTxWI4CdaeX4!j0Hb8/cYtolmoGHstLXOef25BLwxta7RU0XK+dzlk8XYMb+CdC2tQ0ylL4lXfmwgtdWKznzdNTCJ!uF0= 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: g2news2.google.com comp.lang.ada:7621 Date: 2008-09-03T13:35:40+01:00 List-Id: On Tue, 02 Sep 2008 16:50:34 -0400, Robert A Duff wrote: >Ray Blaak writes: > >> Martin Krischik writes: >>> When I was at Polytechnic first language was PL/1, second Pascal and >>> therefore methodology was different. i.E. Don't rely on the execution >>> order of boolean expressing. >> >> This I also agree with, although I admit being used to the short circuit && >> forms in the C-like languages. >> >> But my point is about having the source code be clearer when both >> operands are required to be evaluated, especially when this is a >> possibility: > >It seems to me that two cases come up in practise, for "A and [then] B". >Either I don't care which gets evaluated first, and don't care whether >or not both get evaluated, because there are no important side effects >(that's "A and B"), or I care about order (that's "A and then B"). > >I never see cases where it is important that A and B both be evaluated. > >Counterexamples, please? ;-) Realistic ones, I mean. Given the speed penalty for branches, there are circumstances where it is faster to evaluate both cases than branch around one. In that sense, it would be important (for performance, rather than semantics) to evaluate both cases. But that is properly the compiler's decision to make. I don't think that's what you meant; I believe you meant "important for semantics" 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) - Brian