Evaluation order of "+="

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 12 22:20:45 PDT 2016


On 12.07.2016 19:20, Andrei Alexandrescu wrote:
> On 7/12/16 5:15 AM, Johan Engelen wrote:
>> On Tuesday, 12 July 2016 at 07:57:37 UTC, Johan Engelen wrote:
>>> On Tuesday, 12 July 2016 at 02:27:04 UTC, deadalnix wrote:
>>>>
>>>> There was a very lenghty discussion about this in the past. DMD is
>>>> correct on that one. The semantic is such as :
>>>>
>>>> int plusEqual(ref int a, int b) {
>>>>   a = a + b;
>>>>   return a;
>>>> }
>>>
>>> Thanks.
>>> Could this be added to the spec please?
>>
>> https://github.com/dlang/dlang.org/pull/1429
>
> Great, thanks. I added a comment to that, which in turn caused a bug
> report. What does the community think? -- Andrei

int main() {
     int sum=0;

     int return1_add9tosum() {
         sum += 9;
         return 1;
     }
     sum += return1_add9tosum();
     return sum;
}

pragma(msg, main()); // 1



More information about the Digitalmars-d mailing list