Finding a "safety syntax" for classes

Brendan Eich brendan at mozilla.org
Thu Mar 22 19:42:42 PDT 2012


Russell Leggett wrote:
>
>     Well, I favour constructor because it blends well with the
>     underlying mechanics... there _is_ a property named constructor in
>     a prototype, pointing exactly to the constructor method of that
>     prototype. So if I looks at the class {...} block as a blueprint
>     for how the .prototype of the class will look like, it is the
>     right name.
>
>
> Haha, yes - that too. Forgot to mention it!

I used to think this was convincing as a reason to prefer 'constructor' 
over 'new', but then Dave Herman pointed out that the syntax does not 
magically wire up the class binding or expression result to the 
'constructor' property -- there's still a magic extra semantic attached 
to the name. Given this, we could choose a shorter name (and impute 
'constructor' from it).

/be


More information about the es-discuss mailing list