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

Questions about GetValue() in Runtime Semantics Evaluation of the with Statement in 13.11.7 #1297

Closed
sakura90 opened this Issue Aug 26, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@sakura90

sakura90 commented Aug 26, 2018

Hi,

Some questions about the following steps in 13.11.7.

13.11.7 Runtime Semantics: Evaluation
WithStatement : with ( Expression ) Statement

  1. Let val be the result of evaluating Expression.
  2. Let obj be ? ToObject(? GetValue(val)).
  3. Let oldEnv be the running execution context's LexicalEnvironment.
  4. Let newEnv be NewObjectEnvironment(obj, oldEnv).
  5. Set the withEnvironment flag of newEnv's EnvironmentRecord to true.
  6. Set the running execution context's LexicalEnvironment to newEnv.
  7. Let C be the result of evaluating Statement.
  8. Set the running execution context's LexicalEnvironment to oldEnv.
  9. Return Completion(UpdateEmpty(C, undefined)).

I guess I understand most of what the evaluation is about. The object of Expression is binded in a new environment, and Statement is evaluated in the new environment.

I am not very sure about the details of some of the steps and I have some questions below.

In step 1, what is the specification type of val?
In step 2, what is the reference that calls GetValue(val)?
If the specification type of val is reference, in step 3 in 6.2.4.8 GetValue(V), what does the base value component of V store? And in step 5b, what does the referenced name component of V store?

If an example is going to help explain, please use the following example or any other examples for the explanation.

var a, x, y;
var r = 10;

with (Math) {
a = PI * r * r;
x = r * cos(PI);
y = r * sin(PI / 2);
}

The questions may be asking too many details of 13.11.7, and it may not be what the way is to understand 13.11.7. If the steps of 13.11.7 are supposed to be conveying the rough steps of how evaluation is done, and my understanding does not have to cover the details, please feel free to let me know.

Thanks,
Patrick

@devsnek

This comment has been minimized.

Show comment
Hide comment
@devsnek

devsnek Aug 26, 2018

Contributor

in your example Expression is an Identifier which gets evaluated into a Reference whose base component is the global environment record, and the referenced name is "Math"

Contributor

devsnek commented Aug 26, 2018

in your example Expression is an Identifier which gets evaluated into a Reference whose base component is the global environment record, and the referenced name is "Math"

@sakura90

This comment has been minimized.

Show comment
Hide comment
@sakura90

sakura90 Aug 28, 2018

Thank you very much. I have got a better understanding.

sakura90 commented Aug 28, 2018

Thank you very much. I have got a better understanding.

@sakura90 sakura90 closed this Aug 28, 2018

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