arrow function syntax simplified

Luke Hoban lukeh at microsoft.com
Tue Mar 27 16:01:28 PDT 2012


>>>> I think fully TCP- compliant do expressions are pure win, FTR.

>> I second this, of course, based solely on the experience I had writing up these examples:

>> https://gist.github.com/2013909

>> https://github.com/rwldrn/popcorn-js/compare/tri-lambda

>> https://github.com/rwldrn/popcorn-js/blob/481338a3ab05ad3423c67b70df690bf19977f9bc/popcorn.js

>> Rick

Looking through those examples, I don't  see any cases where TCP-compliant do expressions are actually needed.  In the original arrow proposal, I believe all the code would be the same, except 10 or so occurrences of "=> do" would become just "=>".  These examples seem to support the simpler approach of the original arrow proposal.

Note that the => is what provides lexical this binding in the body.  The do expressions serve a separate purpose of changing the meaning of return (but not break and continue), and allowing use of completion results as returns (which tends to look a bit awkward in curly brace languages, and I don't believe was used in any of the examples linked above though it's hard to tell for sure due to completion value leak).

Luke



More information about the es-discuss mailing list