Named Arrow Functions

Leonardo Wolter leocwolter at gmail.com
Wed Aug 12 00:45:29 UTC 2015


Well, I found out arguments is actually a reserved word too haha

About that:

 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.

That could be it, right? Since it would be only available at arrow
functions(anon functions too?)

2015-08-11 21:42 GMT-03:00 Leonardo Wolter <leocwolter at gmail.com>:

> 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 <dehrenberg at chromium.org>:
>
>> 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 <leocwolter at gmail.com>
>> 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 <dehrenberg at chromium.org>:
>> >>
>> >> 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 <
>> jacobparker1992 at gmail.com>
>> >> 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
>> >> > es-discuss at mozilla.org
>> >> > https://mail.mozilla.org/listinfo/es-discuss
>> >> _______________________________________________
>> >> es-discuss mailing list
>> >> es-discuss at mozilla.org
>> >> https://mail.mozilla.org/listinfo/es-discuss
>> >
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150811/5fac7504/attachment.html>


More information about the es-discuss mailing list