On Aug 29, 2011, at 1:36 PM, Brendan Eich wrote:
>
> You can't use one integer-valued property to convey two meanings. F.length is
> either minimum non-default/rest parameters, or a count of non-rest
> parameters. I don't see a sane alternative. The count of non-rest parameters
> is not that interesting, since it is one fewer than the full count of all
> parameters (modulo destructuring, where it must count each actual position,
> not all the names of destructured-to formals). That leaves F.length counting
> only non-default/rest params.
>
I can think of two more plausible ones:
1) the number of parameter positions specified in the formal parameter list
include (I'm avoiding talking about names because of destructing):
function (a,b=1,...c) {} //length==3
function (...c) {} // length=1
2) the number of parameter positions (including the rest parameter if
specified) that precede the first default-value parameter (or the end of the
list if there are no default-value parameters):
function (a,b,c) {} //length==3
function (a,b,...c) {} //length==3
function (...c) {} // length=1
function (a=1,b=2) {} //length==0
function (a,b=1) {} //length==1
function (a,b=1,...c) {} //length==1
1) is the simplest rule and in the absence of a clear use case is probably as
good as any other
2) Treats rest as meaning "usually at least one" (unless following a
default-value parameter) which seems to be the way open-ended parameter lists
were interpreted in assigning length to most such Chapter 15 functions. I
think that this rule would yield the most matches with the specified lengths
of chapter 15 functions when their signatures are rewritten using default-value
and rest parameter notation.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss