delegating to typed objects

Kris Zyp kriszyp at
Mon Jul 2 09:21:55 PDT 2007

It appears (at least in the reference implementation) that one there is an
object that has a delegate object that is a typed object, that overwriting
members in the top instance is sometimes not possible. For example:
class C { var x : String; }
c = new C;
function F() {}
f = new F; // f.__proto__ = c
f.x =4;
If you do this c.x now equals "4", that is the value is not set in f, but it
goes up the prototype chain and sets 4 into x (and does implicit
conversion). I think I realize why this is being done. c is of type C, but f
is not of type C, but it still must maintain consistency in the typing of
its members (so instance method can be assured of the right types, I
presume). However, this seems that like quite unintuitive behavior for
JavaScript. Generally one would expect the statement f.x=4; to only affect
f, not f's delegate (c). Was it ever considered to enforce a system where if
f delegates to c, that f must be the same type (or subtype) as c? This could
be done by allowing [[Class]] definition to be inheritable from a delegate
(in this f would not define what [[Class]] it is, but would inherit it's
class definition from c which defines it's class to be C), and maintaining
prototype chain consistency with class inheritance.
Sorry for all the questions, but now that we have a reference
implementation, lots of questions come up...
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Es4-discuss mailing list