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

Use "." notation for all internal slots #574

Closed
annevk opened this issue May 17, 2016 · 8 comments
Closed

Use "." notation for all internal slots #574

annevk opened this issue May 17, 2016 · 8 comments

Comments

@annevk
Copy link
Member

annevk commented May 17, 2016

Instead of "The [[X]] internal slot value of Object" it seems we could simply use Object.[[X]] as is already done for Records. Or is there a reason there is this distinction?

(FWIW, the WHATWG Streams Standard uses Object@[[X]] as convention and folks don't really understand why it's different, including the editor, who defers to this repository.)

@ljharb
Copy link
Member

ljharb commented May 17, 2016

This seems both unconfusing and like it will reduce verbosity without reducing clarity.

@domenic
Copy link
Member

domenic commented May 17, 2016

Yeah, I agree with @ljharb.

At first I thought it was important to distinguish records from JS objects, but doing that by choosing what sigil should be used to access their state is dumb. (I.e., it doesn't help in cases where you're not accessing state, but just using the variable.)

Then I thought it was important to distinguish internal slot access from property access, but that is already done by the [[ notation.

So this seems unambiguous and a clear win.

@jmdyck
Copy link
Collaborator

jmdyck commented May 18, 2016

The spec already has Object.[[X]] in a few places, but I believe all occurrences are for internal methods, not internal slots. E.g., IsExtensible() invokes _O_.[[IsExtensible]]().

@ljharb
Copy link
Member

ljharb commented May 18, 2016

To me, an internal method is just a function-valued internal slot - exactly like an object method is just a function-valued object property.

@jmdyck
Copy link
Collaborator

jmdyck commented May 18, 2016

To me, an internal method is just a function-valued internal slot

(Presumably you mean "function" in a general sense, not the ES-specific sense.)

I think the spec is mostly okay with that interpretation. But note that:

  • [[RegExpMatcher]] is not referred to as an internal method even though it's an internal slot whose value is an algorithm.
  • Invoking an object's internal method is not quite as simple as invoking the value of an algorithm-valued internal slot: the former also sets the 'target' of the invocation.

Bringing it back to the subject of this issue, I think using dot notation makes more sense for internal slots than it does for internal methods; since the spec is already using it for methods, might as well for slots too.

@bterlson
Copy link
Member

bterlson commented Jun 2, 2016

Using dot notation everywhere seems fine to me. Anyone want to tackle this regexp replacement? :-P

@jmdyck
Copy link
Collaborator

jmdyck commented Jun 2, 2016

I'll have a go.

jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jun 2, 2016
Specifically, change:
    the [[Foo]] internal slot of _O_   ->   _O_.[[Foo]]   (132 occ)

    _O_'s [[Foo]] internal slot        ->   _O_.[[Foo]]   (265 occ)

(Resolves issue tc39#574)
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jun 2, 2016
Specifically, change:
    the [[Foo]] internal slot of _O_   ->   _O_.[[Foo]]   (132 occ)

    _O_'s [[Foo]] internal slot        ->   _O_.[[Foo]]   (265 occ)

(Resolves issue tc39#574)
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jun 3, 2016
Specifically, change:
    the [[Foo]] internal slot of _O_   ->   _O_.[[Foo]]   (132 occ)

    _O_'s [[Foo]] internal slot        ->   _O_.[[Foo]]   (265 occ)

(Resolves issue tc39#574)
bterlson pushed a commit that referenced this issue Jun 3, 2016
* Editorial: change "the arguments object" to "_args_"

... in the 4 places where it is preceded by:
    Let _args_ be the arguments object.

(Prep for subsequent refactor.)

* Editorial: use dot notation for accessing internal slots

Specifically, change:
    the [[Foo]] internal slot of _O_   ->   _O_.[[Foo]]   (132 occ)

    _O_'s [[Foo]] internal slot        ->   _O_.[[Foo]]   (265 occ)

(Resolves issue #574)
@bterlson
Copy link
Member

bterlson commented Jun 9, 2016

Alright, this seems done. We don't use it for internal methods, but that can be considered separately in #595.

@bterlson bterlson closed this as completed Jun 9, 2016
domenic added a commit to domenic/browser-payment-api that referenced this issue Dec 13, 2016
Fixes w3c#336. See the history here in whatwg/streams#178tc39/ecma262#574tc39/ecma262#591whatwg/streams@7791c58. My bad for leading people down this path.
domenic added a commit to domenic/browser-payment-api that referenced this issue Dec 13, 2016
Fixes w3c#336. See the history here in whatwg/streams#178tc39/ecma262#574tc39/ecma262#591whatwg/streams@7791c58. My bad for leading people down this path.
marcoscaceres pushed a commit to w3c/payment-request that referenced this issue Dec 13, 2016
Fixes #336. See the history here in whatwg/streams#178tc39/ecma262#574tc39/ecma262#591whatwg/streams@7791c58. My bad for leading people down this path.
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

No branches or pull requests

5 participants