Function.length and Default Parameters

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Oct 10 09:55:43 PDT 2012


ExpectedArgumentCount is used to the the length property of function objects.

We've discussed this extensively before and there doesn't seem to be many plausible use cases for the function length property. 

Given that length isn't very useful alignment with the conventions used for the built-ins seems very reasonable.

BTW, some ES<=5.1 built-ins do not perfectly follow this convention. I've suggested that we change the specified length values for such functions to match the ES6 conventions.  Probably a safe breaking change.

Allen



On Oct 10, 2012, at 9:43 AM, Kevin Smith wrote:

> I notice that the current draft spec says:
> 
> >> The ExpectedArgumentCount of a FormalParameterList is the 
> >> number of FormalParameters to the left of either the rest parameter 
> >> or the first FormalParameter with an Initialiser.
> 
> This aligns ExpectedArgumentCount with built-in functions like Array.prototype.splice in specifying (more or less) the minimum number of arguments for the function to work properly.
> 
> Leaving aside congruence with built-in functions, it seems like it would be more helpful to know the total number of formals, minus the rest parameter.  Is there any other reason to favor the current semantics?
> 
> Kevin
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss



More information about the es-discuss mailing list