Finding a "safety syntax" for classes

Kevin Smith khs4473 at
Tue Mar 27 19:53:20 PDT 2012

Getting back to the "new" vs. "constructor" issue:

The only real practical benefit to using "constructor" is that, if we use
"new", it makes it a little bit harder to create a method named "new":

    class C {
      constructor() {}
      new() {}

    // vs

    class C {
      new() {}
      "new"() {}

Otherwise (per Dave's suggestions) they are equivalent.


1)  The whole point of classes is to provide syntactic sugar for what is
already possible in the language, and

2)  There will be far more constructors (no matter how they are spelled)
than "new" methods, and

3)  It would be rather bizarre to have a "new" method on a class instance
anyway, and

4)  "constructor" is positively cringe-worthy  : )

I conclude that on balance, we will get more benefit from using "new" than
from using "constructor".

Of course, I would be happy to use either one (ever-so-slight cringing
notwithstanding).  ; )

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

More information about the es-discuss mailing list