The class operator: a bridge between object and function exemplers

Allen Wirfs-Brock allen at
Thu Nov 17 15:31:04 PST 2011

On Nov 17, 2011, at 2:05 PM, Brendan Eich wrote:

> On Nov 17, 2011, at 9:04 AM, Allen Wirfs-Brock wrote:
>> OK, I have a fix for the missing constructor problem. See: 
> Nit: [[ctor]], obviously a temporary hack-name. How about [[ClassConstructor]]? or maybe [[DefaultConstructor]]?

> Non-nit: don't we want inherited 'constructor' to work, unless it has the value Object?

let BasicPoint = class {x:0, y:0, constructor() {}};
let BetterPoint = class BasicPoint <| {better: true};
let bp = new BetterPoint;
print(bp.better ? "wrong: bp [[Prototype]] is BasicPoint. prototype" :  "correct: bp [[Prototype]] is BetterPoint.prototype");

BetterPoint needs a [[DefaultConstructor]] for the same reason that the original Point example does. 

We can debate whether Default Constructors should do a:
    if (super.constructor isnt Object) super.constructor()
but that is a more basic question about whether constructors (default or otherwise) should always do implicit super calls.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list