arrow function syntax simplified

Luke Hoban lukeh at
Tue Mar 27 21:39:43 PDT 2012

>> Brendan Eich wrote:
>> > Kevin's analysis contradicts your assertion. Expression-bodied 
>> > functions with bound |this| (or var self=this outside) predominate in 
>> > the code he surveyed.

>> See thread headed by this message:


Yeah - I followed the earlier discussion on the data Kevin gathered, which is great input.  From the spreadsheet linked in Kevin's mail above, it looks like 81% of function expressions had statement bodies, and >50% did not reference this.  While these were cast as BTF candidates, they are also just as much candidates for benefitting from no-frills function shorthand.  

There are a couple of separate topics being tackled simultaneously here (1) 'function' is cumbersome (2) 'var self = this' is cumbersome (3) '{ return }' is cumbersome.  We can separate concerns if we want, and solve only a subset of these problems.  From Kevin's analysis - solving (1) helps 100% of function expressions, solving (2) helps 45% of function expressions and solving (3) helps 9% of function expressions.  That's the basis of my claim that just solving (1) would be a big win. 

Note: Kevin had a follow up where the % of functions with statement bodies was revised, using examples like 'text => { console.log(text) }'.  Since these don't really hit the 'cumbersome' path in case (3) above, I'm quoting the original numbers which characterized where problem (3) was a current pain point.


More information about the es-discuss mailing list