comex <[email protected]> wrote: > On Mon, Jan 13, 2014 at 4:06 PM, Tobias Müller <[email protected]> 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.
You are right, mutations that depend on previous values of the same variable are a problem. For example it would be impossible to determine bounds for i in 'i = i + 1'. But you could shadow i like 'let i = i + 1'. However that is no more mutation but definition of a new variable. Tobi _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
