The class operator: a bridge between object and function exemplers

Allen Wirfs-Brock allen at wirfs-brock.com
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: http://wiki.ecmascript.org/doku.php?id=strawman:class_operator#missing_constructors 
> 
> 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.

Allen 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111117/35a34abd/attachment.html>


More information about the es-discuss mailing list