Function length

Brendan Eich brendan at mozilla.org
Mon Jun 11 12:50:56 PDT 2012


Irakli Gozalishvili wrote:
> Sorry for not being clear about this. Here is a simplified example of 
> the implementation:
> https://gist.github.com/2911817
>
> Also this is just a single particular example, but I expect there to 
> be more. I think what I'm
> really asking for is a way to know if …rest is being used.

Your code doesn't work on a function that uses arguments the old 
fashioned way, though.

Yes, you can make ...rest affect .length and make a dispatcher that 
counts on that, but it's a just-so story and a hard case. Hard cases 
make bad law. If it really matters, we can provide better reflection 
facilities, but I'm pretty sure it doesn't occur enough to justify doing 
so now.

So use the toString hack if you must and let's see if this use-case 
becomes hot.

> Also IMO arrow functions should not have `arguments` at all.

That's already in the proposal:

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

"The /Identifier/ primary expression |arguments| may not be used in an 
arrow function’s body (whether expression or block form)."

/be

>
> Regards
> --
> Irakli Gozalishvili
> Web: http://www.jeditoolkit.com/
>
> On Monday, 2012-06-11 at 11:04 , Allen Wirfs-Brock wrote:
>
>>
>> On Jun 11, 2012, at 10:56 AM, Irakli Gozalishvili wrote:
>>
>>>> I don't think any library should ever rely on f.length. 
>>>
>>> That's a wrong  attitude, there always will be legitimate uses of 
>>> any feature, otherwise such features are just harmful & IMO should 
>>>  be deprecated / removed. 
>>
>> Let me try again.  We don't understand your use case.  You didn't 
>> show us the definition of your dispatch function so we have to guess. 
>>  Even so, It is hard to imagine a "legitimate" use with dynamically 
>> provided functions, particularly as the length values assigned to the 
>> existing built-ins don't follow strict rules. At the very least you 
>> need to help us understand why your use case is both reasonable and 
>> valid.
>>
>> Allen
>>
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list