attributes not allowed on a interface?

liorean liorean at
Tue Apr 22 09:38:22 PDT 2008

On 22/04/2008, Eric Suen < at> wrote:
>  Since attributes not allowed on a interface, for W3C Node interface:
>  interface Node {
>   const unsigned short ELEMENT_NODE = 1;
>  }
>  what is the same statement in EcmaScript 4? I don't see the point
>  why static const attributes is not allowed on a interface?

Entirely based on my own understanding of how it works:
Interfaces in ES4 are only nominal types and signatures, they do not
carry implementation and thus no initialised values. Classes do that.
So, the interface would define the properties, the class that
implement that interface carry the initialisation of those properties.

For the DOM, it all gets a bit bad since the DOM requires multiple
inheritance on the prototype chain if you want to implement a
consistent interface object - prototype inheritance as can be seen in
moz, saf and op but not in ie. In other words, the ES4 inheritance
model does not allow you to implement the DOM interfaces compatibly
with those three browsers strictly using native inheritance systems.
You'd have to implement getters and settters á la the Bindings spec[1]
to achieve that. Those getters and setters are IMO broken, because
they don't ensure a property is looked up in a subtype before they are
looked up in it's supertype[2].

[1] <uri:>
[2] <uri:>
David "liorean" Andersson

More information about the Es4-discuss mailing list