[rust-dev] Appeal for CORRECT, capable, future-proof math, pre-1.0
danielmicay at gmail.com
Sun Jan 12 12:24:08 PST 2014
On Sun, Jan 12, 2014 at 1:23 PM, Tobias Müller <troplin at bluewin.ch> wrote:
> Isaac Dupree
> <ml at isaac.cedarswampstudios.org> wrote:
>> In general, Rust is a systems language, so fixed-size integral types are
>> important to have. They are better-behaved than in C and C++ in that
>> signed types are modulo, not undefined behaviour, on overflow. It could
>> be nice to have integral types that are task-failure on overflow as an
>> option too. As you note, bignum integers are important too; it's good
>> they're available. I think bignum rationals would be a fine additional
>> choice to have (Haskell and GMP offer them, for example).
> Wrapping overflow is just as bad as undefined behavior IMO.
Do you know what undefined behavior is? It doesn't mean unspecified.
> I cannot remember a single case of using signed integers where wrapping would make any sense.
It often makes sense in codecs, hashing algorithms and cryptography.
If you don't have clear bounds and don't want modular arithmetic, you
need big integers.
> And you lose some optimization opportunities.
It's treated as undefined because there are more optimization
opportunities that way.
> So why not take the path of the rust memory management and enforce bounds
> statically? It would need annotations on the types, like lifetimes, but it
> would be very rusty. Like C but safe.
Rust isn't supposed to be really hard to write. Complex dependent typing would
More information about the Rust-dev