arrow function syntax simplified

Brendan Eich brendan at mozilla.com
Tue Mar 27 20:05:35 PDT 2012


Kevin Smith wrote:
> That's exactly the reason I'm suggesting lexically bound |this| for 
> "->" functions, because outside of "methods" (which already have 
> shorter syntax, either via object literal extensions or classes), 
> there doesn't appear to be a great need for function expressions with 
> dynamic |this|.
We could indeed make -> bind |this| by fiat and take a block.

I hate the CoffeeScript deviation, though. It's just confusing for 
anyone who ever learned that fat-arrow binds |this| and thin-arrow doesn't.

If the use-case for block bodies with bound |this| is uncommon enough, 
we could just say "use a good ol' function expression long-hand." Would 
that be so bad, compared to the alternative you're suggesting?

/be


More information about the es-discuss mailing list