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: 1094ba,3354bcb01bfd8111 X-Google-Thread: 103376,bda36258b2fe9834 X-Google-Attributes: gid1094ba,gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!news.glorb.com!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.fortran,comp.lang.ada Subject: Re: Shortcut logicals (was: Re: F200x ) Date: 31 Jan 2005 20:16:11 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <41f94cab$1@news1.ethz.ch> <1107060103.157135.325010@z14g2000cwz.googlegroups.com> <8u2pv0tdd9b1v689rtqc2c2tlm9pn9t1t6@4ax.com> <1107085125.849687.318060@c13g2000cwb.googlegroups.com> <1107096062.786125.100030@f14g2000cwb.googlegroups.com> <10vq094k09igv3c@corp.supernews.com> <1107160100.162171.223490@f14g2000cwb.googlegroups.com> NNTP-Posting-Host: shell01-e.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls4.std.com 1107220573 14689 69.38.147.31 (1 Feb 2005 01:16:13 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 1 Feb 2005 01:16:13 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.fortran:10023 comp.lang.ada:8092 Date: 2005-01-31T20:16:11-05:00 List-Id: "James Van Buskirk" writes: > "James Giles" wrote in message > news:mXzLd.100$xR1.94@bgtnsc04-news.ops.worldnet.att.net... > > > Well, I have the F2003 FCD open right now, in �7.4.3 Masked array > > assignment - WHERE. So, perhaps you can point out what part of > > it resolves the issue I raised: > > > cond1 .and. cond2 .andthen. cond3 .and. cond4 > > > Is COND4 permitted to be evaluated or not? I don't see that > > WHERE tells me. It has a concept of "pending control" which > > I see can be applied on nested constructs, but in the above > > expression, not of the terms actually present are part of any > > "pending" condition. Or, are you talking about some other > > aspect of WHERE entirely? > > OK, I have added comp.lang.ada, so hopefully someone there > can answer the question about the effect of precedence on > your snippet, and also discuss the ergonomics of Ada short- > circuiting logical operators, or whatever they call them. Sorry, I've no idea what the Fortran rules are. In Ada, the above expression is syntactically illegal -- compile time error. You can write: (cond1 and cond2) and then (cond3 and cond4) or: ((cond1 and cond2) and then cond3) and cond4) for example. "and" is just a function call. If you say "X and Y" then X and Y are both evaluated (in either order) and passed to the "and" function. The predefined version of "and" returns True if both are True. But "and then" is a short-circuit control form: if you say "X and then Y", X is evaluated first, and if it's True, you're done. Otherwise (X is False) Y is evaluated. And the syntax rules forbid mixing "and" and "and then" -- you have to use parens. All of these ("and", "and then", "or", "or else", "xor") are lower precedence than most other operators in Ada. So you can write: A <= B and B <= C which means the same as: (A <= B) and (B <= C) The point of "and then" is so you can write things like: Y /= 0 and then X/Y < 10 where X/Y makes no sense if Y is zero. - Bob