simple shorter function syntax

Maciej Stachowiak mjs at apple.com
Mon Jul 26 02:51:04 PDT 2010


On Jul 26, 2010, at 1:06 AM, Cameron McCormack wrote:

>> 
> 
> I think having the braces on the outside would help with the
> aforementioned problem.  The vertical bars don’t particularly grab me
> (not being a Rubyist), but this does:
> 
>  [0, 1, 2, 3].map({ x => x * x }); // optionally { (x) => x * x }?
> 
>  function mapPairs(o, f) {
>    for (var p in o) {
>      f(p, o[p]);
>    }
>  }
> 
>  mapPairs(someObject, { (a, b) => a + '=' + b) });
> 
> (Sorry for adding more options to the discussion — quick rebuttals as to
> why the above wouldn’t work welcome.)

If you allow multiple arguments with this syntax, either with or without parens, you're back to unbounded lookahead required for an LL parser.

Regards,
Maciej

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100726/34ca496f/attachment-0001.html>


More information about the es-discuss mailing list