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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,db5c6b2ef47d4b9e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-21 00:31:23 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!news-hog.berkeley.edu!ucberkeley!newshub.sdsu.edu!newspeer.cts.com!galanthis.cts.com!127.0.0.1.MISMATCH!not-for-mail Sender: kst@king.cts.com Newsgroups: comp.lang.ada Subject: Re: short-circuit control forms References: From: Keith Thompson Date: 21 Jun 2001 00:31:22 -0700 Message-ID: X-Newsreader: Gnus v5.5/Emacs 20.3 NNTP-Posting-Host: 209.68.192.180 X-Trace: 993108682 nntp.cts.com 768 209.68.192.180 Xref: archiver1.google.com comp.lang.ada:8961 Date: 2001-06-21T00:31:22-07:00 List-Id: "Beard, Frank" writes: [...] > It seems to me that the "and" and "or" should have been implemented > in the short circuit form to begin with, instead of requiring > "and then" and "or else". As soon as one of the conditions is FALSE > for "and" or TRUE for "or", there is no need to check the remaining > arguments. If I were designing a language from scratch, I might do something like the following: For an "and" operation, it's unspecified whether the right operand is evaluated if the left operand is false. It's also unspecified whether the left operand is specified if the right operand is false. Order of evaluation is unspecified. Side effects in either operand are strongly discouraged. Compilers should do whatever results in the most efficient generated code. Most code should use "and" unless there's a good reason not to. For an "and then" operation, the left operand is always evaluated; the right operand is evaluted only if the left operand is true (just like Ada's "and then"). Finally a third form would specify that both operands are always evaluated (subject to optimization rules). Perhaps something like and(lhs, rhs). -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> Cxiuj via bazo apartenas ni.