Re: I/O in PURE and ELEMENTAL procedures in Fortran 2008



On May 2, 9:08 am, *** Hendrickson <***.hendrick...@xxxxxxx> wrote:
jamesgi...@xxxxxxx wrote:
....
Since the arguments of a function are always evaluated
before the function itself, this guarantees the AND will
be done without short_circuiting.

[snip]
There's significant controversy about whether or not that is true.

In particular, compilers are getting pretty aggressive about
inlining small external routines. If a short circuiting
compiler inlines your my_and we're literally right back where we
started.

That would violate what little clear semantics the language
has with respect to procedure references. There was a long
discussion of this with respect to MERGE a while back.
People wanted a version that *didn't* evaluate the alternative
that wasn't returned. But the present requirements of the
standard are that, semantically, the arguments are fully
evaluated prior to the procedure evaluation. The property of
not evaluating arguments until the procedure actually references
them is called non-strict. With respect to this issue, Fortran's
procedure semantics are strict.

The bottom line is that any action taken by the committee
that makes it *harder* for the end user to control the meaning
of a program is a negative step. Short-circuiting under the
discretion of the implementer has always been such a bad
design. Either the standard should specify order, or it
should be under the control of the user. The implementation's
job is not to decide semantics, but to efficiently process the
user's intent.

--
J. Giles

"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare


.