holes in spread elements/arguments
seaneagan1 at gmail.com
Thu Sep 29 11:07:01 PDT 2011
Sorry to drag on about array holes, but:
Should holes in spread elements (e.g. [...holeyArray]) and arguments
(e.g. f(...holeyArray)) reflect as holes in the array they are spliced
into to avoid information loss ? The current proposal  reflects
them as `undefined` values.
Spread arguments will reflect in both the `arguments` array and the
rest parameter binding if there is one, so this would allow them to
have holes. The only issue I see is that Function.prototype.apply
reflects holes as `undefined` values in the `arguments` array, so if
`f` is a function whose code loops over `arguments` skipping holes
(most likely via ES5 Array extras), then the following migration could
cause holes to be skipped which were previously not:
This should be rare, since for one thing holey arrays are rare, and
it's unlikely anything important was being done with the `undefined`
values which are now being skipped. If this is an issue, the holes
could only be reflected in rest parameter bindings since they are
meant to replace `arguments` in the long run anyways.
On a separate note, I'm not sure if argument lists should be made
symmetric to array element lists, by allowing them to have holes (e.g.
f(1, , 3)), but it would essentially allow `undefined` arguments to be
ommitted, if that would be considered useful.
More information about the es-discuss