[OT] The Usual Arithmetic Confusions

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sat Feb 5 07:59:21 UTC 2022


On Saturday, 5 February 2022 at 03:48:15 UTC, Adam D Ruppe wrote:
> You want the compiler (and the casts) to call out potentially 
> buggy areas so when it cries wolf, you actually look for a wolf 
> that's probably there.

Well written code would use a narrowing cast with checks for 
debugging, but the type itself is less interesting, so it would 
be better with overloading on return type. But it could be the 
default if overflow checks were implemented.

     byte x = narrow(expression);


If it was the default, you could disable it instead:

    byte x = uncheck(expression);



More information about the Digitalmars-d mailing list