On 12 June 2012 17:21, Felix Böhm <[email protected]> wrote:
> As written before:
>
> function foo(a, b, ...others, c){ … }
>
> behaves the same as
>
> function foo(a, b, ...others){
> var c = others.pop();
> }
>
Sadly, it's not as simple to emulate
function foo(a, b, ...others, c, d) {
}
...using pop. But obviously it can be done one way or another.
When the number of parameters following the rest parameter is greater or
> equal the number of passed arguments, the rest parameter is an empty array
> and the parameters get assigned in order until there are no more arguments.
> Unassigned parameters default to undefined.
>
> When the number of arguments is greater than the number of parameters
> following the rest parameter, then the first(argument-number -
> parameter-number) arguments are passed as the rest parameter.
>
Yes, the rule doesn't seem particularly complicated.
I've definitely seen (and very occasionally used) this sort of thing in the
real world, though not nearly to Node's extent. The beginning and end of
the args list are the only fixed points.
On 12 June 2012 17:21, Allen Wirfs-Brock <[email protected]> wrote:
> For ES6 we have the most important use cases covered. If experience with
> it suggests that some generalizations would add real value we can consider
> them for future editions.
>
Very true, no reason it couldn't be loosened up in ES7 or whatever. And
yet, if not yet implemented in its current form (I have no idea what the
extent of implementation is), the complexity increment does not seem large.
As Felix points out, the algorithm isn't exactly complicated.
-- T.J.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss