Evaluation order of index expressions
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Mon May 25 17:53:21 PDT 2015
On Monday, 25 May 2015 at 17:25:57 UTC, Andrei Alexandrescu wrote:
>> It's not += doing the magic, it's bar(). And it's not limited
>> to
>> concurrency, it happens with every side effect:
>>
>> import std.stdio;
>> void main()
>> {
>> int a = 0;
>> int bar()
>> {
>> a++;
>> return a;
>> }
>> a += bar(); // => a = a + bar()
>> writeln(a);
>> }
>>
>> DMD: 2
>> GDC: 1
>>
>> which one is correct?
>
> GDC. -- Andrei
You made me change SDC to return 2 recently using the following
as an argument (one lwoering per line):
a += foo();
((ref X, Y) => X = X + Y)(a, foo());
http://33.media.tumblr.com/31bb0136f46468417bd3ccac1c52c769/tumblr_inline_nix5v8WXLd1t7oi6g.gif
More information about the Digitalmars-d
mailing list