recursive arrow functions

Brendan Eich brendan at mozilla.org
Sun Apr 1 10:50:45 PDT 2012


While

http://wiki.ecmascript.org/doku.php?id=harmony:completion_reform

hasn't settled the matter, I think it would be "bad" for let and const 
to differ from var in

   y = 33;
   for (var x = 42; x < 0;);

which completes with value undefined according to the completion-reform 
proposal (but completes with 33 in ES1-5; we are using one finger of 
fate to tempt fate with an incompatible change here).

If I change var to let, why should the completion change (under 
completion-reform) from undefined to 42?

/be

Allen Wirfs-Brock wrote:
> On Apr 1, 2012, at 7:59 AM, Brendan Eich wrote:
>
>> Kevin Smith wrote:
>>> This is the workaround, right?
>>>
>>>     const recurse = () =>  {
>>>         // call recurse(), somehow...
>>>     };
>> Yes, with the hassle of hoisting from an expression out to enclosing block or body scope, and of polluting that scope with the name (long-form named function expressions avoid this).
>
>>> If so, then it seems hardly worth any added parsing complexity to support named arrows.
>> Could be.
>
>
> or:
>    (do {let recurse = () =>  {
>               //call recurse(), somehow ...
>              };
>             recurse
>           }
>     )
>
> Plus, if we can define const and let to have completion values, we can get rid of the extra reference to recurse.
>
> Allen
>
>
>
>
>
>> /be
>> _______________________________________________
>> 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
>


More information about the es-discuss mailing list