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

comex comexk at gmail.com
Mon Jan 13 20:56:29 PST 2014


On Mon, Jan 13, 2014 at 4:06 PM, Tobias Müller <troplin at bluewin.ch> wrote:
> int<l1,u1> + int<l2,u2> = int<l1+l2,u1+u2>
> ...
>
> If the result does not fit into an int the compiler throws an error.
> To resolve an error, you can:
> - annotate the operands with appropriate bounds
> - use a bigger type for the operation and check the result.

I remember wondering whether this type of solution would be feasible
or too much of a hassle in practice.  As I see it, many values which
might be arithmetic operands are sizes or counts, and really ought to
be size_t sized, and any mutable variable which is operated on in a
loop can't be bounded with a lot more complexity, so it might lean
toward the latter.


More information about the Rust-dev mailing list