delegating to typed objects

Brendan Eich brendan at
Mon Jul 9 16:40:23 PDT 2007

On Jul 9, 2007, at 4:32 PM, P T Withington wrote:

> On 2007-07-09, at 19:16 EDT, Brendan Eich wrote:
>> Having thought about 1 more, I'd like to point out that it's *not*
>> what ES3 does:
>> js> function F(){}
>> js> F.prototype = d = new Date
>> js> f = new F
>> js> f.__proto__ === d
>> true
>> js> f.setTime(0)
>> typein:10: TypeError: Date.prototype.setTime called on incompatible
>> Object
>> So new F did create an Object instance, and it linked its __proto__
>> (ES1-3 [[Prototype]] internal property) to d. Not what Kris
>> proposes by analogy to ES1-3, so I'm favoring 2 at the moment.
> [Coming late to the party]
> And it has burned me that I could not do that.  I wanted to write an
> 'annotated string' and couldn't because of exactly this restriction.
> Will I be able to subclass built-in types?

Subclass, yes -- provided the superclass is not final.

Subclassing is not what's going on above, though.

>   Or will their methods be
> hard-wired in some way that raises similar issues?

Certainly not for two classes, one a subclass of the other. There you  
get the usual OOP object calculus.


More information about the Es4-discuss mailing list