Multiple assignment

Jonathan M Davis jmdavisProg at gmx.com
Sat Feb 26 01:17:46 PST 2011


On Saturday 26 February 2011 00:51:45 spir wrote:
> On 02/26/2011 04:26 AM, Steven Schveighoffer wrote:
> > Let me fix that for you:
> > 
> > func(j++, y[j])
> 
> That should be illegal: a statement used as expression, but keeping it's
> effect anyway, and not the least kind of, namely an assignment, meaning a
> change of the program state.

Umm. There is no statement used as an expression here. The only statement is a 
function call. Both j++ and y[j] are expressions. Even the function call is an 
expression. It's just that if it's followed by a semi-colon, it becomes a 
statement.

Regardless, the best solution is to make the order of evaluation of the function 
arguments fixed at left-to-right instead of undefined. And as I understand it, 
Walter intends to make D do that at some point. It's just that he hasn't gotten 
around to it yet.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list