Tab Atkins Jr. (2015-02-23T21:53:49.000Z)
d at domenic.me (2015-03-06T00:38:23.028Z)
On Mon, Feb 23, 2015 at 10:34 AM, Brendan Eich <brendan at mozilla.org> wrote: > Why not? The generator would switch on sent value, in a loop. .tee() "clones" an iterator by caching the values returned by the frontmost iterator, and returning the cached values to the lagging iterators rather than running the master iterator itself. So Salvador is right - you can't .send() different values to a lagging iterator, because the iterator only runs once. To do more sophisticated "cloning", the generator has to cooperate with client code, as you say. It has to be able to serialize out its state at any given yield point, so it can jump-start a fresh "clone" at an arbitrary point and return that, rather than the "fake" cloning that .tee() does. (Not saying anything needs to be added right now. Just pointing out the specifics, as it seemed you were talking past each other.)