Comments for JS 1.8 Function Expressions: The Opposite of "Good"
http://wiki.ecmascript.org/doku.php?id=strawman:lambdas
This discussion may be relevant:
http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/eb969b7d402b3078/74565b955d56b182
function ()
Of course, what can clearly be inferred is that I am defining an anonymous function that returns an empty object literal. Oh wait, that's just a function with no body, returning nothing.
Now of course, since the parser does not read the {} as an object literal here, this is invalid syntax altogether:
function ()
So in the end, you have to fall back to:
function () { return { a: 0 } }
So yeah, I would pick a different preamble syntax for anonymous functions to eliminate the parser ambiguity.
In some cases, the word "return" doubles the length of the function body. e.g. in ruby, compare:
a.select {|i| i>3 }.map
with
a.select {|i| return i>3 }.map
fun - as a stripped down lambda-esque function. (x) x + 2 - as shorthand for fun(x)