Yeah., that's what I meant. My proposal is not a keyword, but an hidden variable included at functions (e.g. arguments). Does arrow functions have any limitations about that?
2015-08-11 21:35 GMT-03:00 Daniel Ehrenberg <[email protected]>: > I assume you mean more like this (without factorial): > > x.map((x) => do { > if (x <= 1) { > 1; > } else { > x * recur(x - 1) > } > }); > > One issue is that it's hard to add keywords to JavaScript at this > point. If they're not from the tiny set of remaining reserved words > (enum, anyone?), they can be users' identifiers, and have to be based > contextually on some enclosing syntax, like yield is. > > Another downside is that then, arrow functions have a distinct and > less powerful method of recursing (e.g., nested functions won't be > able to see the binding to the outer one). > > Dan > > On Tue, Aug 11, 2015 at 5:30 PM, Leonardo Wolter <[email protected]> > wrote: > > What about a clojure like recur hidden variable binded to the > bottom-level > > function? > > > > x.map(factorial(x) => do { > > if (x <= 1) { > > 1; > > } else { > > x * recur(x - 1) > > } > > }); > > > > 2015-08-11 21:26 GMT-03:00 Daniel Ehrenberg <[email protected]>: > >> > >> In addition to being hard to parse in general, I don't think this > >> would play very well with the async/await proposal > >> https://tc39.github.io/ecmascript-asyncawait/ , which wants to have > >> arrow functions like > >> > >> async (x) => ... > >> > >> Because we can't count on async as a keyword, your proposal would > >> create an ambiguity. > >> > >> On Tue, Aug 11, 2015 at 1:49 PM, Jacob Parker < > [email protected]> > >> wrote: > >> > I did look, but couldn’t find anything on named arrow functions were > not > >> > included. I do sometimes find cases where I want recursion inside a > class > >> > function definition, and still need access to `this`. Was it just > seen as > >> > syntax bloat, or were there any complications to implementing it? > >> > > >> > Obviously a contrived example, but something like this (using do > syntax > >> > too) > >> > > >> > x.map(factorial(x) => do { > >> > if (x <= 1) { > >> > 1; > >> > } else { > >> > x * factorial(x - 1) > >> > } > >> > }); > >> > > >> > _______________________________________________ > >> > 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 > > > > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

