[rust-dev] Appeal for CORRECT, capable, future-proof math, pre-1.0

Gábor Lehel glaebhoerl at gmail.com
Sun Jan 12 12:55:17 PST 2014

On Sat, Jan 11, 2014 at 11:18 AM, Marijn Haverbeke <marijnh at gmail.com>wrote:

> I am not aware of an efficient way to provide
> automatic-overflow-to-bignum semantics in a non-garbage-collected
> language, without also imposing the burden of references/move
> semantics/etc on users of small integers. I.e. integers, if they may
> hold references to allocated memory can no longer sanely be considered
> a simple value type, which doesn't seem like it'd be a good idea for
> Rust.
> If there is a good solution to this, I'd love to find out about it.

This is a very good point. My thinking w.r.t. checking for overflow used to
be that if you're taking the performance hit for it, you might as well
expand to a big integer instead of failing, because if the use case is
indexing into an array, then the bounds check will catch it, and in other
use cases it's likely preferable.

But checked integers are POD and big/expanding ones aren't, which is a big
advantage for the former.

All of this really makes me wish hardware supported overflow checking in an
efficient manner natively. If it can throw an exception for divide by zero,
then why not overflow? (...I expect someone will actually have an answer
for this.)

> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140112/50889a9b/attachment.html>

More information about the Rust-dev mailing list