Warn about do nothing expressions?

MattCoder somekindofmonster at email.com.br
Sat Mar 29 10:29:50 PDT 2014


On Saturday, 29 March 2014 at 16:31:48 UTC, Frustrated wrote:
> On Friday, 28 March 2014 at 19:57:13 UTC, MattCoder wrote:
>> On Friday, 28 March 2014 at 19:35:22 UTC, Frustrated wrote:
>>> which means, i = is the previous value of j(before increment).
>>> This should hold true when j is an alias for i.
>>
>> In this case: i = i++;  Means:
>>
>> "i" is incremented by one, but the value assigned in "i" is the
>> previous one. That's it.
>>
>> For me there's nothing wrong here.
>>
>> Matheus.
>
>
> One thing you are getting wrong/leaving out is that i++, even 
> in an assignment, increments i.

I see your pain pal... so I took a look around:
http://dlang.org/expression.html

And according the page above:

"Expressions

C and C++ programmers will find the D expressions very familiar,
with a few interesting additions.

Expressions are used to compute values with a resulting type.
These values can then be assigned, tested, or ignored.
Expressions can also have side effects.

Order Of Evaluation

The following binary expressions are evaluated in strictly
left-to-right order:
[i]
OrExpression, XorExpression, AndExpression, CmpExpression,
ShiftExpression, AddExpression, CatExpression, MulExpression,
PowExpression, CommaExpression, OrOrExpression, AndAndExpression
[/i]

The following binary expressions are evaluated in an
implementation-defined order:

AssignExpression, function arguments

It is an error to depend on order of evaluation when it is not
specified. For example, the following are illegal:

i = i++;"

Matheus.


More information about the Digitalmars-d mailing list