[rust-dev] "let mut" <-> "var"

Ziad Hatahet hatahet at gmail.com
Wed Jan 29 23:47:09 PST 2014

On Wed, Jan 29, 2014 at 8:31 PM, Haoyi Li <haoyi.sg at gmail.com> wrote:

> Sorry to parachute in to the conversation (long time lurker) but just to
> add to the statistics, the Scala standard library and compiler has
> 11875:54575 ratio of mutable (var) vs immutable (val) declarations, so it
> seems to match pretty well with the numbers you guys are seeing in the rust
> libraries.
That's interesting. However, Scala's `val` is the equivalent of Java's
`final`, and does not imply "total" immutability. For non-primitive types,
it only means that the reference is fixed to being bound to a specific
object. It does not mean that that object itself is immutable (unlike Rusts
`let`, or C++'s `const*`/`const&`). It is better than nothing, but it does
give a false sense of security at times. I really wish more languages
adopted Rust's way of doing immutability (I think D does something
similar); I wonder why it never caught on in the more popular languages.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140129/0169ca9b/attachment.html>

More information about the Rust-dev mailing list