What's the order of argument evaluation for functions
Jens Mueller
jens.k.mueller at gmx.de
Wed Apr 27 14:19:02 PDT 2011
Steven Schveighoffer wrote:
> On Wed, 27 Apr 2011 16:22:45 -0400, Jens Mueller
> <jens.k.mueller at gmx.de> wrote:
>
> >Hi,
> >
> >on page 50 TDPL states
> >"All arguments are evaluated left to right before fun gets invoked."
> >That means
> >int i;
> >writeln(++i, ++i);
> >is supposed to print
> >"12".
> >and is valid.
> >But on http://www.digitalmars.com/d/2.0/expression.html
> >func(++i, ++i);
> >is defined as an error.
> >Is the evaluation order for function calls undefined or it is left to
> >right?
>
> Both :)
>
> The answer is, the current spec says it is an error. However, TDPL
> is usually considered to be what the spec *will* be when D2 is
> completed. So expect the left to right evaluation in the future.
> It's likely that the compiler doesn't currently conform to TDPL.
I see. I never seen it like this. So all documentation on
http://www.digitalmars.com/d/2.0/ specifies how it is right now but not
what it will be. And by 'usually' you mean that TDPL can be in error.
So I should rely on TDPL exclusively. Even though I find the online
documentation easier to search.
Jens
More information about the Digitalmars-d
mailing list