The class operator: a bridge between object and function exemplers

Jake Verbaten raynos2 at gmail.com
Thu Nov 17 14:47:23 PST 2011


On Thu, Nov 17, 2011 at 10:05 PM, Brendan Eich <brendan at mozilla.com> 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?
>

For a chain Object <| Parent <| Child. We wouldn't want class Child to
return Parent.constructor because then we would be creating new instances
of Parent whenever we invoke new Child.

We may want [[ctor]] that's generated on Child to invoke Parent.constructor
as a default action rather then just be an empty function.

This would involve changing

> The value of this internal property is a new function object defined as
if by function(){}.

To

The value of this internal property is a new function object defined as if
by function(...args){ super.constructor(...args); }.

Personally I think invoking the super constructor as default behaviour
makes more sense. However we may want to optimise this so it only invokes
the super constructor if the super constructor is not Object.

[ credit to Axel ( https://gist.github.com/1374226 ) for default
constructors invoking super.constructor ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111117/5d952634/attachment.html>


More information about the es-discuss mailing list