Finding a "safety syntax" for classes

Claus Reinke claus.reinke at talk21.com
Fri Mar 23 15:47:54 PDT 2012


>> - could we think of hoisting a class as hoisting its constructor

> This would be a new kind of Temporal deal zone.  I don't think 
> we need it.  Can you show a use case  were the current proposal 
> (class X{} scopes just like const X;) doesn't work.

Thinko of mine, sorry. The reasoning was that

    class X{ constructor(){} }
is short for
    function X(){}

and should be hoisted a such. But with the .prototype properties,
it would be more like

    class X{ constructor(){}; props }
is short for
    {props} <| function X(){}

which doesn't work (nor does hoisting the constructor without
the .prototype properties), while

    class X{ constructor(){}; props }
is short for
    const X = {props} <| function (){}

does make all-or-nothing sense.

Claus
 


More information about the es-discuss mailing list