simple shorter function syntax
Bryan Kyle
bryan.kyle at gmail.com
Fri Jul 23 10:24:39 PDT 2010
I believe # has the advantage of not being a valid character in an
identifier so there won't be any backwards compatibility problems with
existing code.
Your suggestions are legal identifiers so it makes the job of the parser
harder. The parser would have to look further ahead to be able to tell the
difference between an anonymous function and a call to an existing function.
That isn't to say it's impossible, but simplicity speaks for itself :)
On Fri, Jul 23, 2010 at 10:08 AM, Trans <transfire at gmail.com> wrote:
> Hi--
>
> I was reading about the proposed shorter function syntax on the wiki
> and want to comment on it.
>
> http://wiki.ecmascript.org/doku.php?id=strawman:shorter_function_syntax
>
> I do not see how it is advantageous to using a special symbol, '#'.
>
> Taking the example.
>
> [0, 1, 2, 3].map( #(x) {x * x} )
>
> If the goal is just to be more concise, what is wrong with 'f' as an
> abbreviation of 'function'?
>
> [0, 1, 2, 3].map( f(x) {x * x} )
>
> Or 'fn', if it seems a little clearer.
>
> [0, 1, 2, 3].map( fn(x) {x * x} )
>
> Heck you could even use 'y' as an upside down lambda if you wanted.
>
> [0, 1, 2, 3].map( y(x) {x * x} )
>
> Any of these seem a much nicer choice than '#', IMHO.
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
--
Bryan
http://bryan-kyle.blogspot.com
@bryan_kyle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100723/2025fde1/attachment-0001.html>
More information about the es-discuss
mailing list