Interesting paper on the topic of various program patterns implemented in coroutine. As mentioned in a previous post, continuations are a powerful control flow primitive — they can be used for:
Call with Current Continuation Patterns, Ferguson & Deugo
- Escaping recursive procedures and loops
- Reentry into recursion
- Simulating multitasking
The paper covers these patterns, and gives sample implementations.
For those of us playing in Scheme, enjoy.
For those of us not programming in Scheme, it’s not all bad news. Continuation passing style can be used in most functional languages with varying degrees of effort.
And for those of us in C/C++ land, there are tricks you can pull. FC++ has always looked interesting to me, but perhaps mildly impractical. There’s also some lambda support in C++0x, coming to VC10. Lastly, I heard Apple was adding something like lambdas to their C/Obj-C compiler with Grand Central Dispatch.