[rust-dev] Why doesn't rust require "mut" param prefix at call site?
vadimcn at gmail.com
Wed Jan 1 22:06:14 PST 2014
On Wed, Jan 1, 2014 at 9:12 PM, Patrick Walton <pwalton at mozilla.com> wrote:
> There is no "real answer" beyond the one I already gave: that we are
> already precisely as explicit as C, that Rust references do not actually
> have the hidden mutation hazard of C++ references, and that changing would
> place the language in a different space entirely.
Patrick, I disagree with this point. Rust references *do* have hidden
mutation hazard, as do C's and C++'s pointers. In all three, mutation
hazard is only obvious when you take an address of a stack variable.
After that, when you already have a pointer, you pass it around, and never
know who might mutate the underlying object. And let's not forget about
the heap-allocated objects, which start out as pointers in the first place.
Well, since requiring '&' at the original borrow site doesn't really
prevent the "unexpected mutability" problem, why not drop it and eliminate
a bunch of noise from Rust sources? And, again, if "unexpected
mutability" is what concerns people, "mut" annotation is the better way to
fix that, IMHO.
> Please don't suggest that I am (or that anyone else on the list is) being
My apologies, I didn't mean to imply that.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rust-dev