Please tell me this is a bug?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 21 23:13:42 PST 2015


On Sunday, 22 February 2015 at 02:52:47 UTC, Peter Alexander 
wrote:
> On Sunday, 22 February 2015 at 02:35:02 UTC, Adam D. Ruppe 
> wrote:
>> On Sunday, 22 February 2015 at 02:27:30 UTC, Peter Alexander 
>> wrote:
>>> Seems questionable to me. Anyone know the rationale?
>>
>> I actually agree it is a bit questionable, but I think the 
>> difference is += is, conceptually at least, atomic - it is a 
>> single function, append() instead of two calls, 
>> set(calculate()).
>
> I can see where you are coming from, but the fact of the matter 
> is that it is evaluated no differently than a = a + b. Why, in 
> the a += b case, does it somehow become acceptable for the 
> compiler to irresponsibly insert in an implicit narrowing 
> conversion?

It is only equivalent for integral greater than int. It is not 
for smaller integrals or floating point. See my other answer for 
rationale.


More information about the Digitalmars-d mailing list