Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let variables immutable? #7

Open
davej opened this issue May 9, 2015 · 3 comments
Open

let variables immutable? #7

davej opened this issue May 9, 2015 · 3 comments

Comments

@davej
Copy link

davej commented May 9, 2015

In the documentation it says that the following code gives an immutable variable:

let y = "hello"    ;; const variable (immutable)

It compiles to the equivalent javascript and let is not immutable in javascript, only const is immutable.

@breuleux
Copy link
Owner

breuleux commented May 9, 2015

You are right, but it doesn't make any difference in practice because trying to set an immutable variable is a compile-time error in EG. Though, I should probably generate const anyway, if that can somehow help browsers run the code faster down the line.

@davej
Copy link
Author

davej commented May 9, 2015

Ah ok, I didn't realise that it was enforced at compile time.

Yeah, I guess I was also just confused that the semantics of var and let are completely different than semantics of var and let in Javascript. I see that's also how it's done in Swift (and probably other languages), I've just never come across those semantics before.

@MadcapJake
Copy link

According to this, const does cause JS compilation to change but the answer is a bit outdated. However, with ES6 finalized, I think it's definitely a good idea to generate ES6 files with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants