whatwg / webidl

Web IDL Standard
https://webidl.spec.whatwg.org/
Other
407 stars 164 forks source link

Syntactic changes to attributes #488

Open annevk opened 6 years ago

annevk commented 6 years ago

The main drawback I see with explicit getters/setters as suggested in #485 is that we can no longer use the attribute name to also serve as an internal slot (if needed).

In particular, with

  readonly attribute boolean bodyUsed;

you could let IDL take care of ensuring there is an [[bodyUsed]] internal slot and also let IDL take care of defining that the getter returns that (you need to allow for the default to be overridden, but useful defaults are nice).

But perhaps it's not so bad to have to list both [[bodyUsed]] and getter in IDL and be a little more verbose. Not sure.

Opened this as a new issue to not distract from the main goal of making all things JavaScript-y, which I've been a long time supporter of.

littledan commented 6 years ago

I don't understand the contradiction; why can't you use getter/setter syntax and still have it define the internal slot?

annevk commented 6 years ago

You're right. We could always infer it from the getter (unless an override is in place). The only minor problem is you have to define both a getter and setter, but that is just as well as they need their own algorithm too (and might want different types as pointed out elsewhere).