#include #include struct Fibonacci { coroutine c; int fn; // used for communication }; void ?{}(Fibonacci* this) { this->fn = 0; } coroutine* this_coroutine(Fibonacci* this) { } void co_main(Fibonacci* this) { int fn1, fn2; // retained between resumes this->fn = 0; fn1 = this->fn; suspend(this); // return to last resume this->fn = 1; fn2 = fn1; fn1 = this->fn; suspend(this); // return to last resume for ( ;; ) { this->fn = fn1 + fn2; fn2 = fn1; fn1 = this->fn; suspend(this); // return to last resume } } int next(Fibonacci* this) { resume(this); // transfer to last suspend return this->fn; } void main() { Fibonacci f1, f2; for ( int i = 1; i <= 10; i += 1 ) { sout | next(&f1) | ' ' | next(&f2) | endl; } }