#include #include coroutine PingPong { const char * name; unsigned int N; PingPong & part; }; // void ?{}( PingPong & this, const char * name, unsigned int N, PingPong & part ) { // this.[name, N] = [name, N]; &this.part = ∂ // } // void ?{}( PingPong & this, const char * name, unsigned int N ) { // this{ name, N, *0p }; // call first constructor // } void cycle( PingPong & pingpong ) { resume( pingpong ); } void partner( PingPong & this, PingPong & part ) { &this.part = ∂ resume( this ); } void main( PingPong & pingpong ) with(pingpong) { // ping's starter ::main, pong's starter ping for ( N ) { // N ping-pongs sout | name; cycle( part ); } // for } int main() { enum { N = 5 }; PingPong ping = { "ping", N }, pong = { "pong", N, ping }; partner( ping, pong ); } // Local Variables: // // tab-width: 4 // // compile-command: "cfa Pingpong.cfa" // // End: //