Why D is not popular enough?

ag0aep6g via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 21 02:47:15 PDT 2016


On 08/21/2016 07:12 AM, Shachar Shemesh wrote:
> During static analysis, keep both the "most expanded" and the "least
> expanded" type of the expression parsed so far. "Least expanded" is the
> largest type actually used in the expression.

What's "most expanded"?

> 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.


More information about the Digitalmars-d mailing list