How to fix the `class` keyword

Brendan Eich brendan at
Thu Mar 5 04:55:31 UTC 2015

Leon Arnott wrote:
> I do, however, have a small personal grievance about the class syntax: 
> why doesn't it use commas to separate method and accessor properties? 
> Consider the disconnect. Object literal: commas. Array literal: 
> commas. Class literal: no commas. I appreciate that classes are not 
> literals in quite the same sense, in that they aren't really a list of 
> properties that are assigned to a single object, but it still seems 
> quite un-Javascryptic to have property after property with no commas 
> between.

Class bodies are not literals, they're a distinct special form. Do not 
be thrown by method shorthands in object literals -- convergent 
evolution ;-).

One proof that class body is not an object literal is how magic 
constructor is. Another is how `super` works.

Finally, commas are unwanted overhead in the current design. In a design 
that adds data properties, e.g.,

the proposed punctuator is semicolon, which would be required only after 
data properites, not after methods or constructors (which end in braced 
bodies). This is C-like in the sense that C++, Java, C#, etc. are C-like.

So actually, tradition on top of avoiding unwanted overhead in between 
methods today.


More information about the es-discuss mailing list