delegating to typed objects

Kris Zyp kriszyp at xucia.com
Tue Jul 10 08:21:10 PDT 2007


>
> Because it's possible to violate the type constraints on fixtures in
> the non-subclass object created by the function constructor?
>
Not if the instance of F is a instance of C.


>  1. Classes do not constrain types, have to check everything...
> >
> >
Certainly don't want that. However, checking to see if an incompatible
method error needs to be thrown on every method call requires extra
checks as well doesn't it?



>  2. Delegate creation via (new F) given F.prototype = new C and class
> > > C must make an instance of C, not of Object. This is not backward
> > > compatible.
> >
> >
Why not make (new F) be an instance of C if C is a subclass of Object,
otherwise make it an instance of Object? That would maintain backwards
compatibility wouldn't it?


>   In the former
> > > case, you should get a type error. In the latter, you can do what you
> > > say you want, but you have to write the class with extra qualifiers.
> > >
> > >
> >
Type errors is what I want. I would want (new F).x = 4 to throw a type error
if x is defined as a String in C (or I guess if x is defined as a String,
ES4 fixtures cause an implicit type conversion, at least in the ref impl,
but type errors would surely be in order at some point).

Kris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20070710/799c4807/attachment-0002.html 


More information about the Es4-discuss mailing list