3 ms·
> The drawback is that it incurs a performance hit and is therefore only enabled in debug builds by default. D has core library functions to check for integer
by WalterBright 4y ago
> The drawback is that it incurs a performance hit and is therefore only enabled in debug builds by default.
D has core library functions to check for integer overflow. In my not-so-humble opinion, a targeted solution like this is better than a global switch to turn it on and off. Adding is deeply embedded into computation, and very very few are at any risk of overflowing.
- tga_d 4y agoRust also has checked operations (i.e., checked_add/sub/mul/etc. that return None when there's an over/underflow). You use wrapped operations when that's what's supposed to happen, checked operations when that's what's supposed to happen, debug builds to assert check all operations, and release builds to skip checks anywhere they're not explicit.