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

LexicalEnvironment and VariableEnvironment slots [ES5.1] #1056

Closed
dSalieri opened this Issue Dec 28, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@dSalieri

dSalieri commented Dec 28, 2017

Why do we need LexicalEnvironment and VariableEnvironment if we can use one slot of them. When operations with LexicalEnvironment occur, then its contents are stored in a special variable and then the content of the special variable is given to the LexicalEnvironment slot. Not once in the specification there is no interaction between LexicalEnvironment and VariableEnvironment. VariableEnvironment is used only to create bindings and more and more it is not found anywhere. Explain the meaning of these two slots if there is no interaction between them. Need clarity here!

@littledan littledan added the question label Dec 28, 2017

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Dec 28, 2017

Member

It's a bit subtle, but VariableEnvironment is important to implement the way that var declarations are hoisted out of blocks. See the note in 13.3.2 Variable Statement. On the other hand, LexicalEnvironment is used to implement detailed block scoping and variable lookup. I can understand if the notes here are a bit difficult to read; if you have any editorial suggestions for how to organize them to be more apparent, that would be welcome.

Member

littledan commented Dec 28, 2017

It's a bit subtle, but VariableEnvironment is important to implement the way that var declarations are hoisted out of blocks. See the note in 13.3.2 Variable Statement. On the other hand, LexicalEnvironment is used to implement detailed block scoping and variable lookup. I can understand if the notes here are a bit difficult to read; if you have any editorial suggestions for how to organize them to be more apparent, that would be welcome.

@littledan littledan closed this Dec 28, 2017

@dSalieri

This comment has been minimized.

Show comment
Hide comment
@dSalieri

dSalieri Dec 29, 2017

Yes, I read this note. But I did not learn anything new for myself. Yes in ES6 appeared let and const that complicated the ECMAScript architecture. By notes of variable declarations it is visible that it is written down in LexicalEnvironment, and that in VariableEnvironment.

  1. In the specification it is said that LexicalEnvironment and VariableEnvironment are initialized by the same value - they contain the same content when entering in the execution context. Further only LexicalEnvironment can change, but not VariableEnvironment. If I correctly understand let and const declarations make LexicalEnvironment different from VariableEnvironment?

  2. Can you give an example with a pseudo-code where you can not do without VariableEnvironment? In another way, I do not know how to comprehend the meaning of these two slots without an example on a pseudo-code or an explanation in which moments you can not do without VariableEnvironment, where it is very important!

dSalieri commented Dec 29, 2017

Yes, I read this note. But I did not learn anything new for myself. Yes in ES6 appeared let and const that complicated the ECMAScript architecture. By notes of variable declarations it is visible that it is written down in LexicalEnvironment, and that in VariableEnvironment.

  1. In the specification it is said that LexicalEnvironment and VariableEnvironment are initialized by the same value - they contain the same content when entering in the execution context. Further only LexicalEnvironment can change, but not VariableEnvironment. If I correctly understand let and const declarations make LexicalEnvironment different from VariableEnvironment?

  2. Can you give an example with a pseudo-code where you can not do without VariableEnvironment? In another way, I do not know how to comprehend the meaning of these two slots without an example on a pseudo-code or an explanation in which moments you can not do without VariableEnvironment, where it is very important!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment