On Wed, Nov 6, 2013 at 10:38 AM, Oren Ben-Kiki <o...@ben-kiki.org> wrote:
> Coming from Haskell, I realize some of the background of using this syntax
> form. But looking at my code, I sometimes wish I could just write `x: Foo :=
> foo();` instead of `let x: Foo = foo();`. All these `let`s in the code seem
> noisy. I suppose this was an explicit design decision - I wonder if anyone
> can say something about why one form was used over the other?

Haskell doesn't have assignment, so in Rust the `let` keyword makes it
easy to visually distinguish updates from declarations. It also makes
some of the dataflow analyses in the compiler easier (for example,
it's easier to do the analysis that tells you which variables, if any,
are used before initialization if you know where all the declarations
are).

Cheers,
Tim

>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@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@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to