Brendan Eich (2015-02-23T19:11:40.000Z)
Benjamin (Inglor) Gruenbaum wrote:
> > Why not? The generator would switch on sent value, in a loop.
>
> Well, let's say we have an iterator that does nothing once, returns 
> what was sent to it the first 5 times and then is done:
>
> ```js
> function* gen(){
>   var res = yield;
>   for(var i = 0; i < 5; i++){
>     res = yield res;
>   }
> }
>
> var iter = gen(), res = {}, i = 1;
> iter.next();
> do {
>   res = iter.next(i++);
>   console.log(res.value);
> } while(!res.done);
> ```
>
> How would you clone that with a switch?

The switch has to go on the inside -- the generator author has to 
cooperate with client code to make something that can be "cloned".

It could be this is too great a hardship, but we need more evidence, not 
contrived examples.

/be
d at domenic.me (2015-03-06T00:37:36.714Z)
The switch has to go on the inside -- the generator author has to 
cooperate with client code to make something that can be "cloned".

It could be this is too great a hardship, but we need more evidence, not 
contrived examples.