Short-circuiting (was Re: I/O in PURE and ELEMENTAL procedures in Fortran 2008)



On May 2, 9:34 am, Beliavsky <beliav...@xxxxxxx> wrote:

<snip>

I'd bet the committee has considered something like

if (f(x) .andif. g(x)) then

forcing f(x) to be evaluated first, but the idea must never have been
approved.

Searching the J3 web site I see that Van Snyder has proposed .ANDTHEN.
and .ORELSE.
http://j3-fortran.org/doc/meeting/170/04-390.ps and that ***
Hendrickson has proposed http://j3-fortran.org/doc/meeting/170/04-410r1.txt

"two new elemental pseudo-functions


ANDTHEN (A1 ,A2 [, A3, ...AN] )
ORELSE (A1 ,A2 [, A3, ...AN] )

Arguments:
A1, ...AN Logical, of any kind, they must be conformable

The arguments are evaluated in sequence, left to right, one at a time.
Evaluation of the arguments stops when ANDTHEN encounters a FALSE
value, ORELSE encounters a TRUE value, or when the last argument has
been evaluated. The result of the function is the value of the last
argument actually evaluated. (This is equivalent to the AND or OR,
respectively, of all of the evaluated arguments.)"

According to the Sep 2006 J3 work plan http://j3-fortran.org/doc/standing/links/010.ps
, ANDTHEN and ORELSE "were not to be pursued at this time".

.