esdiscuss at feedic.com
Tue Jun 12 07:37:04 PDT 2012
The big question is whether Function#length should represent minimum or the
maximum amount of arguments. That means that a rest parameter could have
zero elements, and optional parameters could fall back to their default
value. The minimum approach wouldn't count them, the maximum would expect
the most and return positive infinity as soon as the rest parameter is
Both approaches have their right to exist. With the maximum approach, the
length property could even become a setter: By setting it, the values
always default to the defined value, and rest parameters have a maximum
It would be nice to get both getters.
(Brendan, I'm sorry for sending you this message twice.)
2012/6/11 Brendan Eich <brendan at mozilla.org>
> Irakli Gozalishvili wrote:
>> Sorry for not being clear about this. Here is a simplified example of the
>> https://gist.github.com/**2911817 <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:
> "The /Identifier/ primary expression |arguments| may not be used in an
> arrow function’s body (whether expression or block form)."
>> 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.
>> es-discuss mailing list
>> es-discuss at mozilla.org
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss