Do you mean automatic comma insertion? Waldemar pointed out hazards involving [] and other combinations that use a lexeme that can be a prefix bracket form or a binary connective. On that basis I believe TC39 rejected comma elision as proposed for object literal (initialiser, sic, ECMA-262 says) syntax.

/be

Axel Rauschmayer wrote:
I’ve never seen it written quite this way. #1 is indeed the best argument against object literal (I thought we were calling them object initializers?) syntax for class declarations.

I wonder, though, if comma-separation can’t be learned, especially if trailing commas can be added (which is legal in ES5):

let obj = {
    foo: 123,
    method() {
    }
    bar: "abc",
}

Manageable and the exact analog of semicolon separation.

On Mar 21, 2012, at 9:04 , Brendan Eich wrote:

Erik Arvidsson wrote:
This is why, if we ever agree on class syntax we might want to consider being
opinionated and prevent such usage.

I'll see and raise: class syntax should use a restrictive body plan that's not an object literal specifically so it can't have data properties where it has prototype methods and accessors. You might argue for an object literal with method definition shorthand and get/set accessors, and just ban data properties (p:42, e.g.) but:

1. People will expect them and we can't add them in the future without adding the footgun or diverging from object literals in how data properties bind instance properties, while methods and accessors bind prototype properties.

2. The comma separation is a pain, and unnecessary with bespoke class syntax, so usability says we should avoid it.

/be
_______________________________________________
es-discuss mailing list
[email protected] <mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss


--
Dr. Axel Rauschmayer
[email protected] <mailto:[email protected]>

home: rauschma.de <http://rauschma.de>
twitter: twitter.com/rauschma <http://twitter.com/rauschma>
blog: 2ality.com <http://2ality.com>

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to