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

Notation for internal slot, property, dictionary access #165

Open
littledan opened this issue Oct 23, 2017 · 9 comments
Open

Notation for internal slot, property, dictionary access #165

littledan opened this issue Oct 23, 2017 · 9 comments

Comments

@littledan
Copy link

I'm not sure if this is all out of the scope of the infra spec, but it's a point of confusion for me as a new web spec author: I'm never quite sure what the right notation is for three things:

  • Accessing an internal slot of an object (object's \[\[Foo]] internal slot vs object.\[\[Foo]])
  • Getting a property of a JavaScript object (? Get(object, "property") vs object.property vs something in between)
  • Accessing a member of a WebIDL dictionary (dictionary.member vs I'm not sure)

If this guide, or some other specification (WebIDL?) could clarify, that would be helpful. It's hard for me to figure this out from current specs, as I've been corrected on style issues even when taking style directly from other recent specs.

cc @tobie

@tobie
Copy link
Collaborator

tobie commented Oct 23, 2017

So afaik it's:

  • Accessing an internal slot of an object: object.\[\[Foo]] (ES-spec notation).
  • Getting a property of a JavaScript object: Get(object, "foo") (ES-spec notation).
  • Accessing a member of a WebIDL dictionary: dictionary["foo"] (Infra notation).

@domenic
Copy link
Member

domenic commented Oct 23, 2017

Property and dictionary access seem reasonably well-defined by ES and Web IDL.

Internal slots are tricky since many web specs have effectively borrowed the notion from ES without a formal definition that applies beyond the ES realmecosystem. (E.g. it's technically not defined that internal slots can exist on Web IDL objects, as opposed to the JS objects they correspond to.) I'm not sure whether that's an Infra-level thing or a Web IDL-level thing. There's a Web IDL issue at whatwg/webidl#258 with some previous discussion.

@domenic
Copy link
Member

domenic commented Oct 23, 2017

Another thing worth noting, although again hard to say whether something so ecosystem-specific belongs in Infra, is that in most web specs, it'll be supremely rare to use ES Get() notation, because everything will have been converted to e.g. a dictionary, instead of needing raw property access.

@littledan
Copy link
Author

Maybe Infra isn't the right doc for it, but it'd be nice if somewhere, there were a "web spec notation beginner's guide", or at least a designated, "look at this particular spec--it's in the most modern form". I'm not sure how someone is supposed to start out when there are so many documents.

@domenic
Copy link
Member

domenic commented Oct 23, 2017

You may be interested in https://docs.google.com/document/d/1cRVD1k-hDBGfLVwTG14P_ZqJLM4d5-Z4vpwYFb_4qks/edit?usp=sharing , which is a rough draft collection of resources I once wrote up for someone else.

@jyasskin
Copy link
Member

jyasskin commented May 1, 2023

My impression is that the editors' consensus has moved away from talking about internal properties as "slots" (like we used in Streams), and now prefers using HTML's pattern of "An X 'has a' <dfn for=X>Y</dfn>." Is that impression right?

cc/ @dlaliberte and @tabatkins

@annevk
Copy link
Member

annevk commented May 2, 2023

I think for the web platform that is correct as it's a bit more readable without the square brackets.

There are of course places such as Web IDL and certain algorithms in HTML that need internal slots for parity with JS.

@tabatkins
Copy link
Contributor

Oh, I wasn't aware the consensus had shifted. I've used slots in a lot of my specs to refer to the internal value of an attribute.

However we do it, tho, we should formalize in IDL and/or Infra.

@domenic
Copy link
Member

domenic commented May 8, 2023

Yes. I regret introducing the unnecessarily-complex internal slot notation, along with its implications from ES, into the ecosystem. My bad; I was young and thought that the ES spec was the best spec ever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

6 participants