whatwg / infra

Infra Standard
https://infra.spec.whatwg.org/
Other
118 stars 95 forks source link

Notation for internal slot, property, dictionary access #165

Open littledan opened 6 years ago

littledan commented 6 years ago

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:

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 commented 6 years ago

So afaik it's:

domenic commented 6 years ago

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 https://github.com/heycam/webidl/issues/258 with some previous discussion.

domenic commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.