29 Jul 2010 29 Jul '10
Greg Ewing wrote:
Anders J. Munch wrote:
Right, yield_if_true is a regular function, that's the whole point.
What if it needs to call yield_() more than once? If it's just a regular function, then it has no ability to be suspended at the point of yield and resumed.
I meant a regular function from the point of view of the compiler. The implementation would be special, of course. And therein lies the rub: It's unimplementable in CPython, alas. It could work in an implementation with a non-recursive eval loop, but if I'm not much mistaken, CPython recurses the eval loop even for a pure-Python function call.