Even simpler lambdas

Tab Atkins Jr. jackalmage at gmail.com
Tue Apr 17 09:05:18 PDT 2012

On Tue, Apr 17, 2012 at 2:33 AM, Peter van der Zee <ecma at qfox.nl> wrote:
> Why can't lambda's be a simple case of a lexically scoped `return`
> keyword with any arguments implicitly defined and accessible through a
> predefined identifier/keyword (much like `arguments` works now)?
> arr.map(return '<'+arguments[0]+'
> class="'+this.getClassName(arguments[1])+'"/>');

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'm not generally a fan of overloading keywords with multiple distinct
meanings.  It makes the language harder to read.


More information about the es-discuss mailing list