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

Samuel Williams space.ship.traveller at gmail.com
Wed Jan 29 19:20:45 PST 2014


What about constant folding? Surely let mut x = 10 is easier for the
compiler to optimise?


On 30 January 2014 16:18, Daniel Micay <danielmicay at gmail.com> wrote:

> On Wed, Jan 29, 2014 at 10:09 PM, Samuel Williams
> <space.ship.traveller at gmail.com> wrote:
> > I agree that it is syntactic salt and that the design is to discourage
> > mutability. I actually appreciate that point as a programmer.
> >
> > w.r.t. this specific issue: I think what concerns me is that it is quite
> a
> > high burden for new programmers (I teach COSC1xx courses to new students
> so
> > I have some idea about the level of new programmers). For example, you
> need
> > to know more detail about what is going on - new programmers would find
> that
> > difficult as it is one more concept to overflow their heads.
>
> Either way, Rust is going to warn when there is unnecessary mutability.
>
> > Adding "var" as a keyword identically maps to new programmer's
> expectations
> > from JavaScript. Writing a program entirely using "var" wouldn't cause
> any
> > problems right?
>
> Rust has block scope, so `var` would match what `let` does in JavaScript.
>
> > But, could be optimised more (potentially) if using "let" for immutable
> parts.
>
> It really doesn't introduce any potential optimizations.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140130/310748ca/attachment.html>


More information about the Rust-dev mailing list