Even simpler lambdas

Peter van der Zee ecma at qfox.nl
Tue Apr 17 15:05:38 PDT 2012

On Tue, Apr 17, 2012 at 10:11 PM, Brendan Eich <brendan at mozilla.org> wrote:
> François REMY wrote:
>> I kinda like it.
> I don't, but what's more, Tab's point has come up already in TC39 in similar
> settings. I doubt this will fly. It's hard to see 'return' in an expression
> as different from 'return' at statement level. That's a readability problem
> that I suspect would sink this if it were to get to TC39.

I don't agree. The return-statement keyword is very much
distinguishable from the return-lambda keyword. How often do you make
the mistake for a function declaration vs function expression?

On Tue, Apr 17, 2012 at 6:05 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote:
> This doesn't seem simpler than:
> arr.map((x,y)=> '<' + x + 'class="' + this.getClassName(y) + '"/>');
> Your other variants that shorten the 'arguments' name are better, but
> don't appear to offer much of a win.  They also prevent you from using
> the argument list to good effect, such as by giving them descriptive
> names or using destructuring and rest args.

I can see that point. However, as François points out, we very often
use lambdas in contexts where the arguments don't really need a name
in simple expressions, and could be named if you need slightly more
complex lambdas. As for spread, you'll still have access to the
arguments array (or $ or whatever you wanna end up with). A simple
slice will suffice.

- peter

More information about the es-discuss mailing list