On Mar 27, 2012, at 5:08 PM, Luke Hoban <[email protected]> wrote: > Great to see the arrow syntax proposal moving forward. > > I think I missed a step though in the reasoning for moving to this proposal > vs. the previous arrow proposal. What problem did the previous proposal have > that is addressed with the new proposal?
The ambiguity between a block body and an object literal expression body, which we would prefer to resolve in favor of object literal. The solutions considered before this edit were: * http://wiki.ecmascript.org/doku.php?id=strawman:block_vs_object_literal * Two-token lookahead restriction per http://wiki.ecmascript.org/doku.php?id=strawman:arrow_function_syntax&rev=1307297899#grammar_changes Both are hairy and not near consensus in TC39. The first isn't backward-compatible on edge cases that probably exist on the web. The second is future-hostile. > There's a couple concerns I have with complexity added in the new version of > this proposal: > > 1) => and -> look similar, but have multiple points of difference. Both what > is allowed on the RHS and also binding of 'this'. That will likely make this > harder to explain and harder to reason about code on quick inspection. Early errors help, and users learn. There is even a "YAGNI" opinion that says => is all you need, and Kevin Smith actually wrote an analysis tool to measure incidence, which supports this view. > 2) This version seems to more or less rely on 'do expressions' to make the => > form fully usable, which are more of a departure from current JS than arrow > syntax itself. What was the reason to disallow statement bodies on the RHS > of =>? See above, block vs object literal. Restricting => to have only an expression body and -> to have only a block body is the simple, brute-force solution. "When in doubt, use brute force." I think fully TCP- compliant do expressions are pure win, FTR. /be > > Luke > > -----Original Message----- > From: [email protected] [mailto:[email protected]] > On Behalf Of Brendan Eich > Sent: Tuesday, March 27, 2012 12:44 PM > To: es-discuss > Subject: arrow function syntax simplified > > http://wiki.ecmascript.org/doku.php?id=strawman:arrow_function_syntax > > Use => only with an expression body (do-expressions if accepted allow > statements and combined with => compete with block-lambdas). > > Use -> only with body block, as for long-form function. > > I deferred other accretions. > > In a rush here, comments and corrections welcome and I'll edit as I can. > > /be > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

