Self-recursion and arrow functions
jorge at jorgechamorro.com
Sun Mar 17 04:02:39 PDT 2013
On 17/03/2013, at 10:43, Claus Reinke wrote:
>> I understand, but it's still a limitation of arrow functions that they rely
>> on arguments.callee to self-reference. Relying on the defined name
>> they're assigned to suffers from the "can be redefined" problem. NFE's
>> don't suffer this problem and can completely avoid `arguments` in ES6
>> for all use cases Arrow functions, currently, cannot.
> Neither arguments.callee (not available in strict) nor let (clumsy to
> use in expressions) are needed for self-reference
> var rec = (f) => f((...args)=>rec(f)(...args));
> var f = (self)=>(n)=> n>1 ? n*self(n-1) : n;
God, my eyes, they're bleeding!
Sorry arrow functions but this isn't a better JS.
More information about the es-discuss