Even simpler lambdas

Andrea Giammarchi andrea.giammarchi at gmail.com
Mon Apr 23 01:22:03 PDT 2012

sorry mate, thumbs down here as well ... confusing with RegExp too, no easy
spread, neither shorter, abuse of dollar sign within code and no nested
possibility if not through arguments trap and extra vars declarations ... a
bit "meh" compared with what's already in place as proposal.


On Tue, Apr 17, 2012 at 11: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])+'"/>');
> arr.map(return '<'+$0+' class="'+this.getClassName($1)+'"/>');
> arr.map(return '<'+$[0]+' class="'+this.getClassName($[1])+'"/>');
> Or maybe the hash sign...
> arr.map(return '<'+#0+' class="'+this.getClassName(#1)+'"/>');
> It's going to be hard to come up with a solid grammar for allowing
> statements this way though (return {foo:bar} would be an objlit, not a
> block with label). Is that why it's not being considered?
> You could work around that by restricting grammar for `return` and
> `{`. So `return{` would always start a block. I'm aware that this is
> also currently valid syntax for returning an object literal, but I
> think objections over introducing more restricted grammar rules trumps
> that anyways... :)
> Anyways, I like it because it's short, consise, and it feels very
> intuitive to me. We'd basically overload the return keyword much like
> the function keyword is right now. As a statement it'd remain the
> same. As an expression it becomes shorthand notation for a function.
> - peter
> _______________________________________________
> 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/20120423/e5d4d623/attachment.html>

More information about the es-discuss mailing list