W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2011

[DOMCore] Re: ECMAScript Object equivalence classes proposal

From: David Bruant <david.bruant@labri.fr>
Date: Sat, 02 Apr 2011 22:36:24 +0200
Message-ID: <4D9788C8.3010508@labri.fr>
To: Brendan Eich <brendan@mozilla.com>
CC: es-discuss <es-discuss@mozilla.org>, www-dom@w3.org
[Adding DOMCore to the discussion]

Le 02/04/2011 21:16, Brendan Eich a écrit :
> On Apr 2, 2011, at 11:44 AM, David Bruant wrote:
>> Hi,
>> This proposal is another attempt to address the DOM Element+EventTarget
>> multiple inheritance issue in ECMAScript.
> That issue was resolved by putting EventTarget on the inheritance
> chain. See
> http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#node
> and
> http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html 9.2 DOM Core
> "|Node
> <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#node>| now
> inherits from |EventTarget
> <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventtarget>|.."
> In general, WebIDL is not spec'ing multiple "instanceof" inheritance
> any longer. It is explicitly linearizing to work best with JS.
Does it mean that each node within a MathML document will inherit from
EventTarget as well?
Or any node found in any parsed XML document retrieved through
I think it does unless you create different "Node" constructors. Tell me
if I'm wrong.

> And instanceof EventTarget is now a non-issue.
In a way, I'm glad it is. However, my point (in the initial thread:
was more to address the multiple inheritance problem in general and to
take Element (Node, now) and EventTarget as an example of this (I should
have made it clearer, sorry).
A solution has been found for the DOM, but what for other applications
which would have need for multiple inheritance? Should they linearize
their inheritance too?
If another interface is required to be implemented by Nodes, are you
going to force this new interface to inherit from EventTarget or
EventTarget to inherit from it?

I am worried by the sentence "It is explicitly linearizing to work best
with JS."
Are you expecting all application authors to rethink their inheritance
architecture "to work best with JS"? Shouldn't it be the other way
around, namely improve JS to make it a good language to implement what
people need to implement (multiple inheritance as an example)?

We are lucky here and now that there are only two interfaces to inherit
from and that it makes sense in most cases (not all!) that Node inherits
from EventTarget, but it is not a long term solution and it is not
applicable to all situations.

I think that multiple inheritance is a use case that requires a generic

I agree that my proposal (== being an equivalence relation (for objects
only) and "instanceof" using == instead of === to determine inheritance)
comes with a cost (relatively small in my opinion), but it has the
advantage of providing a very generic response to multiple inheritance.
It has the benefit, for instance to not force all nodes to inherit from
EventTarget for instance.

I wasn't strong on the syntax of my proposal (third optional argument to
Object.create). Any alternative that suits TC39 will be fine to me.
And if there is no good syntax, I think that the multiple inheritance
problem should be addressed in another way anyway.

Received on Monday, 4 April 2011 16:57:26 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:17 UTC