Re: [heycam/webidl] [wip] First pass at adding internal slots (#495)

> I don't think the percentage of slot-backed attribute is as high as 95+%. Especially if you take into account special setter logic that isn't just "set to the value", but also performs some state-checking or validation.

Having to do extra stuff isn't relevant to my point. In all those cases, the *definition* of the slot would be absolutely identical boilerplate, endlessly repeated. Much better if Bikeshed just does it for you automatically, so can jump straight into referring to it.

The % of attributes which *don't use anything like a slot at all*, and instead are purely backed by getter/setter code, is very small. Just look at any random spec.

Note that I'm not implying any guarantees about what's *in* the slot. Just that most attributes store/retrieve *something* from private storage on the instance.

The % of attributes that do nothing but store/retrieve an IDL value from an internal slot is likely high enough to be worth automatically addressing, but that's, I think, a larger discussion.

---

As per earlier discussion, having *most* slots actually written in the IDL is... weird. As stated by others earlier, slots don't necessarily have the same types as attributes; they can take Infra types too.

I'd be okay with a very low-information way of indicating *additional* private slots (beyond what's used just to back corresponding attributes).  For example, in <https://drafts.csswg.org/css-font-loading/#fontface-interface>, all of the attributes have trivial backing slots, just storing/retrieving an IDL value. In addition, the interface has `[[Urls]]` and `[[Data]]`, which are internal slots used for other things, but not exposed via trivial accessors. Being able to write

```
interface FontFace {
  ...
  slot [[Urls]];
  slot [[Data]];
}
```

would be nice, as it (along with all the implicit attribute backing slots) tells you precisely what data will be associated with the object right there in the IDL, rather than requiring digesting all the associated prose.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/495#issuecomment-447493273

Received on Friday, 14 December 2018 22:07:16 UTC