arrow syntax unnecessary and the idea that "function" is too long

Kyle Simpson getify at gmail.com
Mon May 9 01:40:27 PDT 2011


> Do I understand you that the idea here is 'function' without the 
> 'function' keyword? I think this has a pretty bad 
> backwards-incompatibility with ASI:
>
> x = (x)
{ return x }
>
> Which way should this parse?

My reading of Rick's gist was:

(x = (x)
{return x})

The outer ( ) removes the ASI ambiguity. FWIW, I'm not terribly excited by 
this syntax, but I like it better than ->.

One thing that troubles me about the goal/movement to have a shorter 
"function" syntax... It seems like all the examples we exchange for it are, 
on principle, single-line functions. From a readability standpoint, I think 
it's a little deceptive to judge a syntax like that, without considering how 
it will look for a longer, non-trivial function. How easy will it be to scan 
for a function's start/end if the biggest visual signal for a function start 
(aka, "function") is gone and is replaced by that rather non-descript -> 
which, as was said earlier in a thread, looks a lot like existing operators.

Since in the real world, functions are usually a lot more than a single 
return statement or a single assignment, I think we should at least keep in 
mind the readability (or lack thereof) of how these proposals look when 
there's 10, 20, 100 lines in a function... By the same token, how easy is 
the readability when there's 2-4 levels of nested functions (the module 
pattern, etc)?


--Kyle



More information about the es-discuss mailing list