(x) => {foo: bar}
Jasper St. Pierre
jstpierre at mecheye.net
Mon Jan 5 15:03:06 PST 2015
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".
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".
On Mon, Jan 5, 2015 at 1:40 PM, Brendan Eich <brendan at mozilla.org> wrote:
> Mark Volkmann wrote:
>
>> My apologies. I meant to say that Traceur doesn't support returning a
>> literal object from an arrow function with syntax like this:
>>
>> let f = x => ({foo: bar});
>>
>> However, I just tested it again and it works fine. I could swear this
>> didn't work a few months ago. Maybe it was fixed recently. I'm happy!
>>
>
> Cool -- you are supporting Caitlin's thesis that we can pedagogue around
> the footgun. I hope so.
>
> Still leaves http://wiki.ecmascript.org/doku.php?id=strawman:block_vs_
> object_literal as an option for ES7. Comments welcome.
>
> /be
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
--
Jasper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150105/f1f30f06/attachment.html>
More information about the es-discuss
mailing list