Lua-Style Coroutines in C++

  • Wouldn't "create", "getcurrent" and "switch" be better primitives for coroutines [0]?

    Having a concept of caller and callee complicates the maintenance of a large number of "concurrent" coroutines that does different things, and "yield" can be implemented by just using a global variable.

    [0]: http://pypy.readthedocs.org/en/latest/stackless.html#corouti...

  • Most C++ implementations throw their hands up at setjmp/longjmp/setcontext/makecontext.

    Even if it appears to work, it's a dangerous set of routines to use in C++.