Finding a "safety syntax" for classes

Kevin Smith khs4473 at
Wed Mar 21 08:51:00 PDT 2012

> I think there's probably still wiggle room. Perhaps in the future, new()
> could be added with additional semantics...

This may be a possibility.  Presumably in such a future it would be a
static error to have both a "constructor" and a "new".

> Anyway, unless we are going to really make classes distinct from
> functions, I'm not sure how we could enforce super in the way you describe
> without affecting it in other forms. Can you only extend classes created
> using "class" syntax?

No - any function (constructor) can be to the right of "extends".  Again,
not necessarily arguing the case either way, but if in some future there
were field initializers then they would presumably be at the top of the
desugared constructor:

function _ctor(a, b, c) {
    // super constructor call?
    // execute field initializers
    // "new" / "constructor" body

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

More information about the es-discuss mailing list