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

Benjamin Striegel ben.striegel at gmail.com
Thu Jan 30 15:20:27 PST 2014


> https://github.com/mozilla/rust/issues/2643

I came here to post that link, you beat me to it. :)

Highly, vehemently, frothing-at-the-mouthly against adding `var` as sugar
for `let mut`. You can see from reading that issue that I too was once a
fan of getting rid of `let mut`, but after using Rust in the years since I
can see how lovely the current setup is. I was the one who initiated the
widespread grepping recently that found that `let` was three times more
common than `let mut`, and I admit I was surprised to find that
immutability was so completely dominant. Immutability is crucial to Rust.
Mutability *must* be explicit. Not having to ever worry about
const-correctness is icing on the cake. Adding an alternative form for `let
mut` would go completely against the spirit of the language.


On Thu, Jan 30, 2014 at 12:18 PM, Tim Chevalier <catamorphism at gmail.com>wrote:

> I'm surprised that no one has mentioned so far that there was a
> previous, exhaustive, discussion of this question on github:
>
> https://github.com/mozilla/rust/issues/2643
>
> As far as I can tell, this thread adds nothing new that wasn't already
> discussed in the comments on #2643. So that strongly suggests to me
> that nothing needs to be changed.
>
> Cheers,
> Tim
>
>
> On Thu, Jan 30, 2014 at 8:49 AM, Steven Fackler <sfackler at gmail.com>
> wrote:
> > The Zen of Python also says "There should be one-- and preferably only
> one
> > --obvious way to do it."
> >
> > Steven Fackler
> >
> >
> > On Thu, Jan 30, 2014 at 11:35 AM, Donaldo Fastoso
> > <donquestion at rocketmail.com> wrote:
> >>
> >> I like python's rational of "consenting adults": Give people the tools
> >> to do the right thing, if they still want to hurt themselves, they may
> >> have a good reason, or they are better of dead! ;-)
> >>
> >> I would argue, that people choosing Rust over C/C++ are choosing it
> >> BECAUSE of safety measures like immutability and wouldn't need
> >> overbearing lectures.
> >>
> >> In all honesty it's not the TYPING of three additional chars "let mut",
> >> but the READING. It interrupts the flow of reading, or better: it's
> >> a bump in the flow of scanning. Source-Code is not prosa, you have to
> >> actively follow the train of thought and guess the intentions of the
> >> author. So improving READABILITY would really be nice, especially
> >> for people coming from other languages. They would probably try to
> >> learn by reading the source from experienced programmers.
> >>
> >> In this case i would also advice against the use of "var", instead
> >> of "let mut", but omitting "let" and leave it to "mut" would be much
> >> easier to read and understand.
> >>
> >> so
> >> "let mut x, y;"
> >>
> >> would become:
> >>
> >> "mut x;"
> >> "let y;"
> >>
> >> which would take a possible interpretation-ambiguity away from the
> >> single "let mut x, y", which can be read either as "let mut" for x
> >> and y, or "let mut x" and "let y"!
> >>
> >> So imho "let mut" has at least two pitfalls:
> >>         1) read-bump
> >>         2) ambiguity.
> >>
> >> AFAIK you did a remarkable good job so far, and i have all the faith
> >> you are considering all arguments before coming to a decision.
> >>
> >> Even if some thoughts of the thoughts come form the bad smelling
> >> "lurker"-fraction, which do nothing but making comments about things
> they
> >> possible can't understand! ;-)
> >>
> >> Regards,
> >> Don
> >>
> >> _______________________________________________
> >> Rust-dev mailing list
> >> Rust-dev at mozilla.org
> >> https://mail.mozilla.org/listinfo/rust-dev
> >
> >
> >
> > _______________________________________________
> > Rust-dev mailing list
> > Rust-dev at mozilla.org
> > https://mail.mozilla.org/listinfo/rust-dev
> >
>
>
>
> --
> Tim Chevalier * http://catamorphism.org/ * Often in error, never in doubt
> "If you are silent about your pain, they'll kill you and say you enjoyed
> it."
> -- Zora Neale Hurston
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140130/8c585d63/attachment.html>


More information about the Rust-dev mailing list