[rust-dev] "let mut" <-> "var"
mozilla at mcpherrin.ca
Wed Jan 29 18:56:37 PST 2014
"let mut" is to some degree syntactic salt, in my mind. Minimizing
mutability as the easy thing to do creates better code, I think. That
isn't to say mutability is a bad thing, but more that you should think
about whether you need it when you're writing code.
I'm not convinced the incremental language complexity is worth it. Let
with a pattern is pretty elegant IMHO and I'd rather not mess with it.
On Wed, Jan 29, 2014 at 6:50 PM, Kevin Ballard <kevin at sb.org> wrote:
> On Jan 29, 2014, at 6:43 PM, Brian Anderson <banderson at mozilla.com> wrote:
> > On 01/29/2014 06:35 PM, Patrick Walton wrote:
> >> On 1/29/14 6:34 PM, Samuel Williams wrote:
> >>> Perhaps this has been considered already, but when I'm reading rust
> >>> "let mut" just seems to stick out all over the place. Why not add a
> >>> "var" keyword that does the same thing? I think there are lots of good
> >>> and bad reasons to do this or not do it, but I just wanted to propose
> >>> the idea and see what other people are thinking.
> >> `let` takes a pattern. `mut` is a modifier on variables in a pattern.
> It is reasonable to write `let (x, mut y) = ...`, `let (mut x, y) = ...`,
> `let (mut x, mut y) = ...`, and so forth.
> >> Having a special "var" syntax would defeat this orthogonality.
> > `var` could potentially just be special-case sugar for `let mut`.
> To what end? Users still need to know about `mut` for all the other uses
> of patterns. This would reserve a new keyword and appear to duplicate
> functionality for no gain.
> Rust-dev mailing list
> Rust-dev at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Rust-dev