-
Notifications
You must be signed in to change notification settings - Fork 33
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
How should using const
interact with Script?
#66
Comments
Why couldn't |
using const
interact with _Script_?using const
interact with Script?
The two Runtime Semantics are different:
PutValue falls back to putting the reference into the
InitializeReferencedBinding only inserts into the environment record. |
However the same environment record is used for successive calls to ScriptEvaluation in the same Realm, per the steps above. If a Other than by way of a closure, in |
This comment has been minimized.
This comment has been minimized.
@ljharb, my apologies, I misread.
(emphasis added) I'm concerned it would require a lot of additional machinery in the spec to introduce |
I'm currently leaning towards "Ban at the top level of Script" as the safest bet, since a |
I discussed this at the October, 2021 TC39 meeting, with the proposed semantics being to ban |
Per ScriptEvaluation, scripts are evaluated with the LexicalEnvironment set to globalEnv. That means that all
using const
bindings at the top level of a script would also be tracked in globalEnv, which in turn means that they would persist as a value between on script and the next. This leaves us with three options:using const
at the top level of a Script (i.e., when not inside of a Block or other new lexical environment).(1) seems awkward, because the value persists beyond its scoped lifetime. (2) seems ambiguous and possibly not feasible. (3) seems unfortunate, but probably the safest option.
CC: @wycats, @waldemarhorwat as the currently signed on reviewers.
The text was updated successfully, but these errors were encountered: