Expression evaluation order
Jonathan M Davis
jmdavisProg at gmx.com
Thu Jun 13 17:13:22 PDT 2013
On Friday, June 14, 2013 02:02:23 David Nadlinger wrote:
> On Thursday, 13 June 2013 at 23:25:42 UTC, Jonathan M Davis wrote:
> > Walter has expressed a desire in the past to make it so that D
> > requires that
> > the evaluation order of arguments be left-to-right in order to
> > avoid bugs, and
> > while these aren't exactly function arguments, …
>
> Actually, behind the scenes all three are arguments to *one*
> function call: the druntime array op implementation.
>
> Anyway, my question was mainly about the assignment operator,
> which is obviously not expected to behave lexically left-to-right
> by that test case.
I don't see how the assignment operator could possibly work left-to-right,
though I could see how there might be a question with regards to whether
what's on the left of the assignment operator would be evaluated before what's
on the right when what's on the left is an expression rather than a variable.
Personally, I would expect it to fully evaluate the right-hand side of an
assignment expression before evaluating anything on the left, and I'd expect
the same of any operator which is right-associative, but I'm not aware of
anything official on the matter. All the discussions on the matter that I'm
aware of have referred specifically to function arguments being left-to-right
and said nothing about operators.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list