yield* desugaring

Tab Atkins Jr. jackalmage at gmail.com
Mon May 13 11:15:38 PDT 2013

On Mon, May 13, 2013 at 11:08 AM, Andreas Rossberg <rossberg at google.com> wrote:
> The case I was talking about is simply this:
>   function* g() {
>     yield* [1, 2]
>   }
>   var o = g()
>   o.send(undefined)
>   o.send(5)  // what does this mean?
> But I suppose the answer is that the sent value is just dropped on the
> floor, as per the iterator expression interpretation you gave in the
> other post. Makes sense, I guess.

Yes, because that code is equivalent to:

function* g() {
  yield 1;
  yield 2;

Using .send() instead of .next() makes no difference to this code.
Using .throw() should just percolate the error up to the yield*
expression, as Allen suggested.


More information about the es-discuss mailing list