(x) => {foo: bar}

Rick Waldron waldron.rick at gmail.com
Tue Jan 6 08:16:01 PST 2015


On Tue Jan 06 2015 at 2:18:47 AM Isiah Meadows <impinball at gmail.com> wrote:

> > From: Alex Kocharin <alex at kocharin.ru>
> > To: Gary Guo <nbdd0121 at hotmail.com>, "brendan at mozilla.org" <
> brendan at mozilla.org>
> > Cc: "es-discuss at mozilla.org" <es-discuss at mozilla.org>
> > Date: Tue, 06 Jan 2015 06:59:52 +0300
> > Subject: Re: (x) => {foo: bar}
> >
> > 06.01.2015, 06:38, "Gary Guo" <nbdd0121 at hotmail.com>:
> >
> >
> > Though I am strongly negative, but there actually is such an
> implementation. The REPL of node will parse {a:1} as object literal while
> {a:1;} as block.
> >
> >
> > Node.js REPL wraps all the statements in parentheses. Therefore `{a:1;}`
> becomes `({a:1;})` which is a syntax error.
> >
>
> Not in my REPL (node 0.10.33).
>
> ```
> $ node
> > {a:1;}
> 1
> > {a:1}
> { a: 1 }
> ```
>
> What the Node.js REPL effectively appears to do, AFAICT, is some sort
> of evented try-catch.


No, that's not what it does. Alex was close, but not exactly right. The
REPL will test input and wrap if necessary:
https://github.com/joyent/node/blob/master/lib/repl.js#L266-L271

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150106/9ca1bb0d/attachment.html>


More information about the es-discuss mailing list