simple shorter function syntax

Kris Kowal kris.kowal at
Fri Jul 23 10:20:24 PDT 2010

On Fri, Jul 23, 2010 at 10:08 AM, Trans <transfire at> wrote:
>  [0, 1, 2, 3].map( f(x) {x * x} )
>  [0, 1, 2, 3].map( fn(x) {x * x} )
>  [0, 1, 2, 3].map( y(x) {x * x} )
> Any of these seem a much nicer choice than '#', IMHO.

While I agree on principle, the real challenge here is to find syntax
that will not break existing programs by promoting an existing
variable name to a keyword.  Otherwise, you'd have to look ahead to
the curly brace block to distinguish the variable name from the
function keyword.  It's been a long time since I wrote a parser of
this kind, but as I recall, looking ahead is generally hacky.

function expression: name, argument list, block

Of course, if that approach were taken, the spec might as well forgo
having a function keyword at all and use the name or absence of a name
to distinguish a named and anonymous function expression.  But again,
I expect there would be resistance to looking ahead.

Kris Kowal

More information about the es-discuss mailing list