> Was this some unsafe-language benchmark shootout? Even if those are
> important due to some "Rust is slow, clinical tests prove it" bogo-PR
> effect, I assume you would disable overflow checking along with array-bounds
> checks in unsafe Rust code.

Clojure basically does this. By default, math operations (even on
primitives) are checked for overflow and throw an exception if
overflow occurs. There is a dynamic variable, *unchecked-math*, which
will allow silent overflow when set to true. It defaults, correctly
IMO, to false. There are also operations which will promote to
BigIntegers on overflow, but you must use them explicitly (+', *',
etc), as they always return boxed numbers. More can be found in the
Math Operations[1] section of the numerics documentation. The Clojure
team chose this path after trying several others as being the most
practical option. It's still quite fast, but also safe.

I would like to see checked math by default, which can be disabled
with some unsafe block. I would also like it if unsafe blocks
described what safety guarantees they gave up, so I could write code
like:

unsafe(math) { x + y }

to get the fast path where overflow is not checked.

[1] http://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics

jack.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to