holes in spread elements/arguments
seaneagan1 at gmail.com
Thu Sep 29 12:14:41 PDT 2011
On Thu, Sep 29, 2011 at 1:31 PM, Allen Wirfs-Brock
<allen at wirfs-brock.com> wrote:
> On Sep 29, 2011, at 11:07 AM, Sean Eagan wrote:
>> 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.
> You need to read the draft ES6 spec. It specifies that spread used in array literals preserves holes.
Sorry. I agree.
> I haven't written the spec. for spread in argument lists but clearly interior holes need to be passed as undefined. Trailing holes in a spread in the final argument position could be trimmed but that would mean that:
So you don't think holes should appear in rest parameters or
`arguments` ? The only reason I can think of to require that is that
old code may expect `arguments` not to contain holes, but then it
could be spec'ed that holes only appear in rest parameters. Beyond
that is seems like it would make sense to be consistent with array
literal hole preservation.
More information about the es-discuss