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: Have RequireInternalSlot return the object #2355

Closed
wants to merge 1 commit into from

Conversation

jmdyck
Copy link
Collaborator

@jmdyck jmdyck commented Mar 21, 2021

Most invocations of RequireInternalSlot take the form:

    1. Let _O_ be the *this* value.
    2. Perform ? RequireInternalSlot(_O_, [[Foo]]).

If we modify RequireInternalSlot to return the object (when successful), we can reduce this idiom to:

    1. Let _O_ be ? RequireInternalSlot(*this* value, [[Foo]]).

I think this is slightly better, because it tells you in a single line that there are requirements on the this value.

Most invocations of RequireInternalSlot take the form:
    1. Let _O_ be the *this* value.
    2. Perform ? RequireInternalSlot(_O_, [[Foo]]).

If we modify RequireInternalSlot to return the object (when successful),
we can reduce this idiom to:
    1. Let _O_ be ? RequireInternalSlot(*this* value, [[Foo]]).

I think this is slightly better, because it tells you in a single line
that there are requirements on the *this* value.
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

This is fine, but I’m not convinced it’s actually clearer.

@bakkot
Copy link
Contributor

bakkot commented Mar 24, 2021

This seems marginally worse to me - where previously a reader could infer what RequireInternalSlot did without looking at its definition, now it's not obvious. Interested to hear from others though.

@bakkot bakkot added the editor call to be discussed in the next editor call label Apr 5, 2021
@bakkot
Copy link
Contributor

bakkot commented Apr 7, 2021

Editors are opposed for the reason I gave; closing. Thanks for the suggestion, though.

(We should probably change ValidateTypedArray so that it doesn't return the buffer, to match RequireInternalSlot.)

@bakkot bakkot closed this Apr 7, 2021
@bakkot bakkot removed the editor call to be discussed in the next editor call label Apr 7, 2021
@jmdyck jmdyck deleted the RequireInternalSlot branch April 8, 2021 02:26
jmdyck added a commit to jmdyck/ecma262 that referenced this pull request Apr 8, 2021
ljharb pushed a commit to jmdyck/ecma262 that referenced this pull request Jun 2, 2021
mathiasbynens pushed a commit to mathiasbynens/ecma262 that referenced this pull request Oct 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants