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
Editorial: Fix description of [[ThisMode]] internal slot of Function Object #1463
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I actually prefer the previous commit. This is just noting the possible values of |
Adding the description was suggested in the issue, might have jumped the gun with that one 🙂 Should I revert the commit untill the decision is made, or what's the course of action here? Thanks! |
spec.html
Outdated
@@ -7236,7 +7236,7 @@ <h1>ECMAScript Function Objects</h1> | |||
(lexical, strict, global) | |||
</td> | |||
<td> | |||
Defines how `this` references are interpreted within the formal parameters and code body of the function. ~lexical~ means that `this` refers to the *this* value of a lexically enclosing function. ~strict~ means that the *this* value is used exactly as provided by an invocation of the function. ~global~ means that a *this* value of *undefined* is interpreted as a reference to the global object. | |||
Defines how `this` references are interpreted within the formal parameters and code body of the function. ~lexical~ means that `this` refers to the *this* value of a lexically enclosing function. ~strict~ means that the *this* value is used exactly as provided by an invocation of the function. ~global~ means that a *this* value of *undefined* or *null* is interpreted as a reference to the global object, and *this* value of primitive type is wrapped by its type's wrapper object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the global object" is incorrect anyways - it's "the [[GlobalThisValue]] of the [[GlobalEnv]] value of the current realm", which probably wouldn't help make this much clearer :-)
If ~global~
also implies sloppy mode, then I'd maybe state this like:
Defines how `this` references are interpreted within the formal parameters and code body of the function. ~lexical~ means that `this` refers to the *this* value of a lexically enclosing function. ~strict~ means that the *this* value is used exactly as provided by an invocation of the function. ~global~ means that a *this* value of *undefined* or *null* is interpreted as a reference to the global object, and *this* value of primitive type is wrapped by its type's wrapper object. | |
Defines how `this` references are interpreted within the formal parameters and code body of the function. ~lexical~ means that `this` refers to the *this* value of a lexically enclosing function. ~strict~ means that the *this* value is used exactly as provided by an invocation of the function. ~global~ means that a *this* value of *undefined* or *null* is interpreted as a reference to the global object, and the *this* value is first passed to ToObject. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humm...
I agree that the expression the global object
is incorrect. but I think the global object of current realm
or the [[GlobalObject]] of the current realm
would be shorter and more readable than the [[GlobalThisValue]] of the [[GlobalEnv]] value of the current realm
. do you have any reason to use that sentence?
PS. currentRealm.[[GlobalEnv]].[[GlobalThisValue]]
is always eqauls currentRealm.[[GlobalObject]]
. (8.2.3 SetRealmGlobalObject is only way to change "the global object of current realm" as much as I know.)
anyway,
the this value is first passed to ToObject.
this looks better then my suggestion, I'm totally support this sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currentRealm.[[GlobalEnv]].[[GlobalThisValue]] is always eqauls currentRealm.[[GlobalObject]]
No, not always. It's either that or an implementation-defined object. See InitializeHostDefinedRealm, step 8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you checked next step of it? it calls SetRealmGlobalObject(and this abstract operation makes sure what I just said before.)
anyway, If you meant that currentRealm.[[GlobalObject]]
could not be an "global object"(which spec explains at Clause 18), then I'd love to say that I missed that part.
and.. If I missed something, I'd love to say sorry to you :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ENvironmentSet all browsers supply a different globalThis value from the globalObject value (a window proxy).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb Github's UI is broken, so I manually pushed a commit with your change. Edit: also pushed another slight tweak to the wording. Re: "global object", I agree it's wrong, but I don't have a particular fix in mind for it (@ljharb, it sounded like you didn't think your suggestion was the right approach), so unless someone has a better idea for that right now let's land this as-is and follow up on fixing that description. |
…Object (tc39#1463) Co-authored-by: viktmv <viktmv@icloud.com> Co-authored-by: Kevin Gibbons <bakkot@gmail.com>
Fixes #1305