3 ms·
> you still added the ability for + to throw an exception, which it will never do with ints. Not quite true, the language could implement checked over- or unde
by masklinn 11y ago
> you still added the ability for + to throw an exception, which it will never do with ints.
Not quite true, the language could implement checked over- or under-flows (I believe Swift does)
- jerf 11y ago"Not quite true, the language could implement checked over- or under-flows (I believe Swift does)" I am one of the apparently about ten people who thinks that should be the universal default. The vast bulk of people disagree, and I was trying not to poke the sleeping dog. :)
- masklinn 11y ago> I am one of the apparently about ten people who thinks that should be the universal default. There's a handful of us, a handful! FWIW Rust checks for overflow in debug mode, and while that's elided by default when compiling with optimisations it can be re-enabled with a -Z flag: > rustc test.rs > ./test thread '<main>' panicked at 'arithmetic operation overflowed', test.rs:4 > rustc -O test.rs > ./test Overflowed! > rustc -O -Z force-overflow-checks=on test.rs > ./test thread '<main>' panicked at 'arithmetic operation overflowed', test.rs:4 And of course some languages bypass the whole thing by automatically promoting to dynamically sized integrals.