W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2010

Re: [WebIDL] prototype chains, multiple inheritance, mixin interfaces

From: Jonas Sicking <jonas@sicking.cc>
Date: Sat, 20 Nov 2010 09:52:55 -0800
Message-ID: <AANLkTimwN6KjUx6u=oG67E8cNoFgyS3fSPta4-+18ht_@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: public-script-coord@w3.org
On Sat, Nov 20, 2010 at 8:11 AM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
> On 11/20/10 5:32 AM, Jonas Sicking wrote:
>>>
>>> A related issue.  What happens if a single mixin interface wants to mix
>>> in
>>> into multiple concrete interfaces?  Think nsIDOMEventTarget, unless some
>>> interface inheritance chains get changed.
>>
>> Node implements EventTarget;
>> Window implements EventTarget;
>> Worker implements EventTarget;
>> etc..
>
> Yes, but then if script wants to override addEventListener it has to do it
> separately on everything that implements EventTarget, right?  That's ok, I
> guess...

Yup. I think that's the case in every proposal brought up so far,
including what's in the spec now. It's just a limitation of having a
single prototype chain.

This is why MI even of interfaces should be avoided and why we should try to do

class EventTarget {
  ...
};
class Node : EventTarget ...

instead of

interface EventTarget {
  ...
};
Node implements EventTarget

/ Jonas
Received on Saturday, 20 November 2010 17:53:55 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:03 UTC