On Tuesday, 22 January 2013 at 15:11:41 UTC, bearophile wrote:
Era Scarecrow:

Are you going to check after every little + that you didn't have an overflow?

In debug mode that's the job of a modern well designed language, just like checking an index is inside the bounds of an array every time you perform an array access.

Agreed. However D (compilers) doesn't have an option to check those, I think it was requested but walter said no (due to slower speed I think); Therefore if the compiler won't do it for you, you have to do it yourself. I really wouldn't want to have to use BigInt for everything that can't overflow and then check to make sure I can fit it in my smaller variables afterwards along with the extra move. I wouldn't want to use BigInts everywhere, and long's aren't needed everywhere either.

Of course if an attribute was added that checked just those functions for important overflows then it could help, but in truth it kinda clutters the signatures with something that isn't an important attribute. Guess 'CheckedInt' could work in those cases, but that's more during runtime and release rather than debugging.

Reply via email to