<p dir="ltr">On 25 May 2015 01:10, "Timon Gehr via Digitalmars-d" <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br>
><br>
> On 05/25/2015 12:36 AM, Iain Buclaw via Digitalmars-d wrote:<br>
>><br>
>><br>
>>  > This comes up once in a while. We should stick with left to right<br>
>> through and through. It's a "simple" matter of getting somebody on the<br>
>> compiler team to find the time for it. -- Andrei<br>
>>  ><br>
>><br>
>> I find it is not as clear cut as that.  In gdc, there is a compiler flag<br>
>> that tells the optimizer to honour left to right evaluation, and because<br>
>> of both what you say and the agreement of others, it seems natural to<br>
>> have this turned on by default.<br>
>><br>
>> However, this has an interesting side effect with operations with side<br>
>> effects.  Ie: foo += bar() could either produce expected or surprising<br>
>> results.<br>
>><br>
>> Hint, the LTR order - foo = foo + bar() - gives the most surprise in my<br>
>> experience from users.<br>
>><br>
><br>
> I think I still don't get it. What is the surprise? That bar() is evaluated before the value is written to foo?</p>
<p dir="ltr">That foo is cached before bar() is evaluated.</p>
<p dir="ltr">The context here involves concurrency where bar() calls yield and makes changes to foo before returning to assign the updated results.</p>