Coroutines and continuation passing style
Chapter 6: Implementing iterators the easy way: 6.4
Last updated: 2/24/2008
In my initial manuscript, I suggested that the language design team might not have considered iterator blocks being used for the continuation passing style coding that the Coordination and Concurrency Runtime supports. Fortuately, Eric corrected me on this and provided more information:
Though I'm sure the design team did not anticipate that this would be used by robots, the fact that iterators are a form of coroutines was well understood by the design team.
And yes, coroutines are handy for implementing CPS in languages which do not support it natively, though they are not strictly necessary. Really all you need are first-class functions.
Since iterators provide closure semantics and are objects you can pass around, they act like first class functions. That they also act like coroutines is a nice bonus.
See my blog for a discussion of how to implement a simple CPS system in Jscript by using first-class functions.
Really, is there anything he hasn't written a blog post about?