(x) => {foo: bar}
Frankie Bagnardi
f.bagnardi at gmail.com
Mon Jan 5 12:01:48 PST 2015
That's good news, thanks for the strawman link. Is it correct to assume
this with that proposal?
var f = (x) => (y) => {x, y};
f(1)(2) // => {x: 1, y: 2};
On Mon, Jan 5, 2015 at 12:54 PM, Brendan Eich <brendan at mozilla.org> wrote:
> Caitlin Potter wrote:
>
>> The strawman changes to the grammar are still ambiguous :(
>>
>> `() => {}` -> noop or Object or SyntaxError? If SyntaxError, ...why?
>>
>
> No, the strawman addresses this: "An empty pair of braces |*{}*| other
> than at start of /Statement/ is an /ObjectLiteral/." The grammar is
> unambiguous. Notice the meta-? in the first production RHS below, and the
> non-empty-producing nature of the second:
>
> Block:
> { UnlabeledStatementFirstList? }
> { WellLabeledStatement StatementList? }
>
> UnlabeledStatementFirstList:
> UnlabeledStatement
> UnlabeledStatementFirstList Statement
>
>
> The final piece of the puzzle is here:
>
> We retain the |[lookahead ∉ {*{*, *function*}]| restriction in
> /ExpressionStatement/. At the start of a statement, |*{*| can be the start
> of a block only, never an object literal.
>
> I think hacking around this would not get rid of the footgun, but would
>> just make it more complicated to understand the footgun, personally.
>>
>
> You mean replace the footgun with a smaller one, maybe one so small it
> doesn't matter. Saying that the proposal doesn't get rid of the footgun
> means it still remains impossible to write x => {p: x} and not get what
> Frankie and others want: an arrow returning an object. But the proposal
> does fix that footgun.
>
> How often do you really want an empty object instead of a block with no
> statements?
>
> /be
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150105/8aede6ca/attachment.html>
More information about the es-discuss
mailing list