arrow function syntax simplified

John J Barton johnjbarton at
Wed Mar 28 08:20:33 PDT 2012

On Tue, Mar 27, 2012 at 9:39 PM, Luke Hoban <lukeh at> wrote:

> >> 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.

Your claim is based on assuming that the value of this improvements are all
the same.  I think this is wildly inaccurate.

I don't think the difference between 'function' and any proposed
alternative can even be measured scientifically. Maybe after a year of
intense training the difference between typing "function" and "fn" could be
measured. The difference for readers could be larger, but does anyone have
clear measurements showing more symbolic syntax is always
faster/better/cheaper or even that any proposal fits this criteria? I think
no. I am not claiming that any such test need to be applied. All I am
saying is that the net advantage here is not equal to the other categories.

On the other hand, failing to bind 'this' is something that I believe every
single JS developer hits routinely. It has cost them time to recognize and
recover. The net advantage of a better bind mechanism still depends upon
many issues, but this problem has much bigger impact that eight vs two

The third problem is too obscure for me.

Deciding based on Kevin's data to support an alternative to 'function' but
not support bound 'this' would be unwise in my opinion.


> 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.
> Luke
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list