Re: Let's not BE NP-hard, shall we...?
On Aug 4 2011, Ian McIntosh wrote:
NM>
NM> DZ > I am aware that Fortran specifies that the order of
NM> DZ > evaluation is effectively NOT specified. I am also
NM> DZ > aware that, while it IS specified in C, it is also
NM> DZ > routinely ignored.
NM>
NM> That's misleading. It is EXPLICITLY unspecified for Fortran,
The truth is in between. The Fortran standard is more complicated than
either specified or unspecified.
Within an expression, the standard lets the programmer use parentheses to
explicitly partially specify the evaluation order or leave it unspecified.
In other situations it is partly unspecified.
I am afraid that you have missed my point, and I feel that you are
being a bit misleading. My point was that, not just is it effectively
unspecified, it is EXPLICITLY unspecified. Only the significance of
parentheses is specified, and that does NOT include the parentheses
around the arguments in function calls.
Also, your examples with function calls may confuse people who are not
Fortran experts. Unlike in C, whether impure function calls are completely
undefined behaviour or have a more constrained set of possibilities has
been a matter of debate for at least 40 years. And the attitude of WG5
is a lot harder to that one than it was 40 years ago. In particular,
even the following statement is dubious:
. f(g(x),h(x)) has an unspecified order between the g and h
function calls (and if either changes x or a global variable read by the
other, or does I/O, it can affect the result).
but splitting the last one into three statements
t1 = g(x)
t2 = h(x)
f(t1,t2) has a specified order.
However, this is not an appropriate forum to discuss that particularly
arcane and controversial aspect of the Fortran standard! Nor, for that
matter, the equally arcane but entirely different way that C has related
ambiguities, which are subtly different between C90, C99 and C1X.
Regards,
Nick Maclaren.