July 2000 Draft
JavaScript 2.0
Core Language
Interfaces
|
Sunday, April 30, 2000
Interfaces behave much like classes except that an interface I is not a supertype of a class C that
implements I. Instead, an instance c of C may be coerced to type I, which creates
an instance i of I. Coercing i to type C yields the original instance c.
It is undefined whether c ==
i.
An interface may have both concrete and abstract members, but it may not have constructors.
In the absence of name conflicts, an interface I's properties may be accessed as properties of any instance
c of a class C that implements I. However, it is legal to define an interface I
with a member m with the same name as a member of class C and yet have the two members be different.
It is also legal for a class to implement two interfaces I and J both of which have a member named m
and have the two m's remain distinct. Which one gets extracted when one performs the member lookup operation c.
m
depends on whether c was last cast to one of the interfaces or to an object type.
Waldemar Horwat Last modified Sunday, April 30, 2000 |