Why D is not popular enough?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 21 10:26:24 PDT 2016


On 8/21/2016 2:47 AM, ag0aep6g wrote:
>> Upon use of the value, resolve which type to actually use for it. If the
>> use type requests a type between least and most, use that type for
>> evaluating the entire expression. If the use requests a type outside
>> that range, use the one closest (and, if the use is below the range,
>> complain about narrowing conversion).
>
> So when only ubytes are involved, all calculations would be done on ubytes, no
> promotions, right? There are cases where that would give different results than
> doing promotions.
>
> Consider `ubyte(255) * ubyte(2) / ubyte(2)`. If the operands are promoted to a
> larger type, you get 255 as the result. If they are not, you have the equivalent
> of `ubyte x = 255; x *= 2; x /= 2;` which gives you 127.

That's right.

The thing is, programmers are so used to C integral promotion rules they often 
are completely unaware of them and how they work, despite relying on them. This 
is what makes changing the rules so pernicious and dangerous.

I've had to explain the promotion rules to professionals with 10 years of 
experience in C/C++, and finally stopped being surprised at that.

D does change the rules, but only in a way that adds compile time errors to 
them. So no surprises.

(Nobody knows how function overloading works in C++ either, but that's 
forgivable :-) )


More information about the Digitalmars-d mailing list