(x) => {foo: bar}

Brendan Eich brendan at mozilla.org
Mon Jan 5 15:06:28 PST 2015


Jasper St. Pierre wrote:
> Unless
>
>     x => {foo: bar}
>
> and
>
>     x => {}
>
> both parse as object literals, I'm against your proposal. Either 
> un-paren'd braces are consistently a block, or they're consistently an 
> object literal. Python has had major pains with "i before e except 
> after c" rules to make the language nicer to use, and it's easier to 
> tell people "always add the parens".

Fair.

> A third option is to make x => {foo: bar} a syntax error to steer 
> people away from an accidental footgun, while still making {} a block, 
> and keeping the consistency of "parens around object literals".

Just about too late for ES6, though. Eep!

/be


More information about the es-discuss mailing list