Tab Atkins Jr. (2014-08-20T15:39:08.000Z)
domenic at domenicdenicola.com (2014-09-08T23:17:52.779Z)
> But I think it could be easier if I could do something like > `generator#clone()` returning a new generator object. Generators produce iterables, and you can just use a tee() function to "clone" an iterable. It's not hard to define yourself, and Python has a reference implementation: https://docs.python.org/2/library/itertools.html#itertools.tee > In the same way, to provide a complete control over execution state inside > generators I would like to propose `generator#goto(yieldLabel)` that could > allow the developer to transfer the execution cursor to a labeled yield > sentence. You can currently pass values back into the generator by passing an argument to .next(), and the generator can use that to do whatever it wishes, such as changing its internal state or jumping to a label.