Make -preview=intpromote not suck
Dukc
ajieskola at gmail.com
Wed Oct 28 22:15:10 UTC 2020
On Wednesday, 28 October 2020 at 17:34:10 UTC, Steven
Schveighoffer wrote:
> That ship may have sailed though. The goal is also different. I
> want to *avoid* breaking existing code, except in the case
> where it differs from the expected behavior. The exception in
> all of this is -int.min, which is still not going to work right.
My idea should not break any code, because for every expression
that compiles now the type is still going to be the same. That's
exactly why I want short+short to still be int if not assigned
back to short.
>
> I also wonder how much D coders would tolerate such rules. I've
> used more restrictive languages which don't allow implicit
> conversions in many cases between integer types, and it can be
> painful.
The problem is not casting strictness in general. If I'm dealing
with 32-bit variables, I agree that I want them to trunctate only
via an explicit cast. The problem is the implicit integer
promotion, when I'm not using any 32 or 64-bit. I do not want to
explicitly cast every single expression back to the original type
just because my arithmetic variables have shorter than normal
lengths. That is --very-- ugly.
More information about the Digitalmars-d
mailing list