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

Editorial: Fix description of [[ThisMode]] internal slot of Function Object #1463

Open
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@viktmv
Copy link
Contributor

viktmv commented Mar 1, 2019

Fixes #1305

@zenparsing
Copy link
Member

zenparsing left a comment

Thanks!

@zenparsing

This comment has been minimized.

Copy link
Member

zenparsing commented Mar 1, 2019

I actually prefer the previous commit. This is just noting the possible values of [[ThisMode]]. For details about the actual behavior readers should consult the algorithm steps.

@viktmv

This comment has been minimized.

Copy link
Contributor Author

viktmv commented Mar 1, 2019

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!

@@ -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.

This comment has been minimized.

@ljharb

ljharb Mar 2, 2019

Member

"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:

Suggested change
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.

This comment has been minimized.

@ENvironmentSet

ENvironmentSet Mar 11, 2019

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.

This comment has been minimized.

@jmdyck

jmdyck Mar 11, 2019

Collaborator

currentRealm.[[GlobalEnv]].[[GlobalThisValue]] is always eqauls currentRealm.[[GlobalObject]]

No, not always. It's either that or an implementation-defined object. See InitializeHostDefinedRealm, step 8.

This comment has been minimized.

@ENvironmentSet

ENvironmentSet Mar 11, 2019

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 :(

This comment has been minimized.

@ljharb

ljharb Mar 11, 2019

Member

@ENvironmentSet all browsers supply a different globalThis value from the globalObject value (a window proxy).

This comment has been minimized.

@ENvironmentSet

ENvironmentSet Mar 11, 2019

@ljharb Oh, I see. thank you for comment :)
@jmdyck thank you too :))

@ljharb ljharb requested a review from erights Mar 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.