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 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: g2news2.google.com!news1.google.com!eweka.nl!lightspeed.eweka.nl!feeder.erje.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Vinzent Hoefler Newsgroups: comp.lang.ada Subject: Re: and then... (a curiosity) Date: 3 Sep 2008 21:01:18 GMT Message-ID: <6i8c8uFp5ufgU2@mid.individual.net> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net cSAR3CHTJRyk4g77vk6enwpQ3GNfgMyaCcA1CABXNm6sdeI+rv Cancel-Lock: sha1:VfVE1pfLOQLW1jW12nGhn84vSN4= User-Agent: KCNews/0.98b Xref: g2news2.google.com comp.lang.ada:7626 Date: 2008-09-03T21:01:18+00: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. Hmm. Digging in *really* old (Turbo-Pascal) sourcecode, I found an old map editor: Example #1: -- 8< -- {$IFOPT B+} {$DEFINE OPTB} {$B-} {$ENDIF} for i := 0 to TESTFUNCS - 1 do b := b and MapTest[i](Contents); {$IFDEF OPTB} {$UNDEF OPTB} {$B+} {$ENDIF} -- 8< -- MapTest is a list of procedures I wanted to execute to check the validity of an edited map prior to exporting it. #2: -- 8< -- {$IFOPT B-} {$DEFINE OPTB} {$B+} {$ENDIF} repeat P := Message (Desktop, evBroadCast, cmClose, @C); until ((P = NIL) or (C = cmCancel)); {$IFDEF OPTB} {$UNDEF OPTB} {$B-} {$ENDIF} -- 8< -- Not quite sure, why I did it here. Seems, more than 10 years ago, I lacked commenting properly. ;) Finally #3 (and one of those MapTest functions mentioned above, so one can see why I did it): -- 8< -- {$A+,B-,D+,E-,F+,G+,I+,L+,N-,O+,R-,S-,V+,X-} { ^^ important!!!} [...] function AtLeastOneActor; var b : boolean; i, j : byte; begin b := False; for i := 1 to 62 do for j := 1 to 62 do b := b or (X.mpObj_Data[i][j].odActors <> 0); AtLeastOneActor := b or SaveMsgBox (NOACTOR); end; {AtLeastOneActor} -- 8< -- (Uh, bad code, literal constants...) So, maybe I would generally write it different today, but for an example, it is as real as it gets. Vinzent.