Re: Operator implicit conversion difference

2015-11-06 Thread Ali Çehreli via Digitalmars-d-learn
On 11/06/2015 04:56 PM, BBaz wrote: On Thursday, 5 November 2015 at 13:20:26 UTC, ixid wrote: This may have been overlooked in my other thread so I wanted to ask again: This seems very inconsistent, does a += b not lower to a = a + b? I guess not based on the below: ushort a = ushort.max,

Re: Operator implicit conversion difference

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Thursday, 5 November 2015 at 13:20:26 UTC, ixid wrote: This may have been overlooked in my other thread so I wanted to ask again: This seems very inconsistent, does a += b not lower to a = a + b? I guess not based on the below: ushort a = ushort.max, b = ushort.max; a += b; //

Re: Operator implicit conversion difference

2015-11-06 Thread BBaz via Digitalmars-d-learn
On Saturday, 7 November 2015 at 01:10:01 UTC, Ali Çehreli wrote: On 11/06/2015 04:56 PM, BBaz wrote: On Thursday, 5 November 2015 at 13:20:26 UTC, ixid wrote: [...] What's inconsistent is the integral promotion of the add expression result that stops from 4 bytes int: --- int a, b; a +=

Re: Operator implicit conversion difference

2015-11-05 Thread Ali Çehreli via Digitalmars-d-learn
On 11/05/2015 05:20 AM, ixid wrote: > This seems very inconsistent, does a += b not lower to a = a + b? Apparently not: http://dlang.org/expression.html#AssignExpression It says "The right operand is implicitly converted to the type of the left operand". So, the rules are different. Ali

Operator implicit conversion difference

2015-11-05 Thread ixid via Digitalmars-d-learn
This may have been overlooked in my other thread so I wanted to ask again: This seems very inconsistent, does a += b not lower to a = a + b? I guess not based on the below: ushort a = ushort.max, b = ushort.max; a += b; // Compiles fine a = a + b; // Error: cannot implicitly