Hi, since there isn't currently a dedicated CEP page on generator support, I'm wondering how they should be implemented.
I kind of imagine that once closures are in place, it might be enough to put all local variables of a generator function into a closure to keep their state, and then put a label behind each yield statement and store the current label in the closure whenever we return from the function. That would allow us to just jump to the label on re-entry and continue the execution. I do see that there might be a problem with deallocation of the closure, though, as it's hard to tell when the generator is at an end. So an extended way of doing it would be a transformation of the function into an extension class, where local variables become class attributes. In order to avoid having to split up the function body, it could be transformed into a single __next__ method, and the execution could follow the goto-label scheme as described above. That would even be independent of the closure support, although we might want to avoid code duplication here. Would that make sense? Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
