Earlier quoted context omitted.
One reason is that let takes a pattern, so you can do things like: let (x, mut y) = ... Another reason is that we feel 'mut' more cleanly communicates mutability than 'var.' Another reason is that we prefer immutability by default, and let/var doesn't communicate that as nicely as let and let mut. There are some discissions about this on the ML archives, RFC repo, or discuss, if you're interested.
let (x, var y) = ... can easily express the intention. Also, communication is in the ear of the beholder. Var: variable, that varies. 'Let' would be immutable by default. Thanks for the response anyway.
It's actually entirely reasonable to have an "immutable variable" -- Rust uses this phrase in its error messages and it's perfectly sensible. For example, consider this snippet:
pub fn is_even(x: int) -> bool {
let y = (x / 2) * 2 - x;
if (y == 0) {
return true;
} else {
return false;
}
}
Not very idiomatic, forgive me, but would you say that y "varies"? I would say yes, it varies for each invocation of is_even(). If y didn't vary, "if (y == 0)" would be a nonsense statement. y is certainly immutable -- you can't go assigning new values to it -- but it's definitely a variable.The opposite of "variable" is "a constant," not immutable. 'mut' means "mutable" and "mutable vs. immutable" is the choice here. Rust got this right, I think.