byte + byte = int: why?

Adam D. Ruppe destructionator at gmail.com
Fri Jan 18 17:37:42 UTC 2019


On Friday, 18 January 2019 at 17:26:35 UTC, Mek101 wrote:
> Then why isn't int + int = long? If i did the example above, 
> they wouldn't fit in a int for sure, yet the result is of the 
> same type. Why should byte be any different?

Because C didn't define it that way. And C didn't define it that 
way because of convenience and efficiency on common hardware 
biased toward int (and nowadays with 64 bit, we kept int at 32 
for compatibility basically, the inertia set in).

We have proposed to change it before, but the main policy D has 
right now is "if it looks like C, it works like C or doesn't 
compile at all", so programmer habits and such don't silently 
bite them.


More information about the Digitalmars-d-learn mailing list