Nick Krempel (2014-02-24T23:30:37.000Z)
You presumably mean "... of the form `{done: false}` ...".

The possibility of a "yield" without an assignment expression meaning
"yield a hole" might be left open for the future (so some clients would
treat it the same as "yield undefined", but those who care to distinguish
could do). There would need to be a disambiguation rule for expressions
beginning "yield /" however.

Nick



On 24 February 2014 23:12, Claude Pache <claude.pache at gmail.com> wrote:

>
> Here is an idea for easily defining an "iterator with holes", so that
> `Array.from` could reconstruct a sparse array from an iterable:
>
> Iterators yield IteratorResult objects, which are of the form `{done:
> <boolean>, value: <any>}`. The idea is to produce results of the form
> `{done: true}` (omitting the `value` key) in order to indicate a "hole".
> For consumers that don't want holes (e.g. `for/of` loops), it will be
> equivalent to `{done: true, value: undefined}`, but consumers that are
> willing to make the difference between holes and `undefined` can
> distinguish the two cases.
>
> For instance, successive application of the `next` method on `[1, ,
> 2].values()` will produce the results:
>
>         {done: false, value: 1}  ;  {done: false}  ;  {done: false, value:
> 2}  ;  {done true, value: undefined}
>
> whereas `[1, undefined, 2].values()` will produce
>
>         {done: false, value: 1}  ;  {done: false, value: undefined}  ;
>  {done: false, value: 2}  ;  {done true, value: undefined}
>
> (Naturally, generators won't be able to produce "iterators with holes": if
> you really want such a silly iterable, the punishment is that you are
> obliged to construct it "by hand".)
>
> —Claude
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140224/86388c2a/attachment.html>
domenic at domenicdenicola.com (2014-03-02T22:43:40.826Z)
You presumably mean "... of the form `{done: false}` ...".

The possibility of a "yield" without an assignment expression meaning
"yield a hole" might be left open for the future (so some clients would
treat it the same as "yield undefined", but those who care to distinguish
could do). There would need to be a disambiguation rule for expressions
beginning "yield /" however.