[heycam/webidl] Designing mixins (#363)

We've talked a lot about mixins, but I don't think we've written them down...

The basic idea is to stop using `[NoInterfaceObject]` interfaces + `implements` to do mixins, and give them dedicated syntax. Along the way we can drastically simplify the model; currently, since interfaces are complicated, mixins are complicated. This leads to situations like the one in [the example in @tobie's latest pull request](https://s3.amazonaws.com/pr-preview/tobie/webidl/tojson.html#create-an-inheritance-stack), where you have mixins that inherit from things that have mixins and so on.

We will either eliminate or repurpose `implements`. The only thing you can mix in (either via the `implements` keyword, or via a new one like `mixes` that takes its place) its mixins; you cannot mix in interfaces.

Once we have a clear way to talk about mixins, and a simpler model, we should be able to fix the following bugs that largely derive from confusion about how mixins interact with the rest of the system:

- https://github.com/heycam/webidl/issues/261
- https://github.com/heycam/webidl/issues/164
- https://github.com/heycam/webidl/issues/118
- (...probably more...)

---

Concretely, the biggest simplifications we have lined up are:

- Making it clear that mixins do not create their own interface/interface prototype object, but instead cause the appropriate members to be added to the interface/interface prototype objects of the interface they are mixed in to
- Saying that mixins are not allowed to inherit from anything (this makes no sense as they have no proper JS prototype chain)
- Saying mixins cannot be mixed in to, maybe? I don't think anything does this today, but we should check. It'd make things simpler to not have to recurse and flatten the mixin chain all the time.

-- 
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/issues/363

Received on Monday, 15 May 2017 23:50:25 UTC