How do you emulate Python style generators in your favorite language? I found this one in Scheme. It must be interesting to see other implementations, especially in those languages that don’t have first-class continuations.
How do you emulate Python style generators in your favorite language? I found this
Share
Here is an example in C++ that simulates generators using fibers:
Yield Return Iterator for Native C++ Using Fibers
There are also the primitive C routines setjmp, longjmp to achieve similar results.
(Lua coroutines are implemented with the above method)