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

Merged
merged 1 commit into from May 26, 2020

Conversation

viktmv
Copy link
Contributor

@viktmv viktmv commented Mar 1, 2019

Fixes #1305

Copy link
Member

@zenparsing zenparsing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@zenparsing
Copy link
Member

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
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!

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.
Copy link
Member

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:

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.

Copy link

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.

Copy link
Collaborator

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.

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

Copy link
Member

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@ljharb ljharb requested a review from erights March 2, 2019 21:26
@ljharb ljharb requested review from syg, michaelficarra, bakkot and a team January 3, 2020 06:06
@bakkot
Copy link
Contributor

bakkot commented May 26, 2020

@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>
@ljharb ljharb merged commit d5fdc6d into tc39:master May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fixing description of [[thisMode]] internal slot of Function Object.
7 participants