Hi Greg:
Message: 2
Date: Tue, 23 Oct 2012 12:48:39 +1300
From: Greg Ewing
It does, in the sense that a continuation appears to the Scheme programmer as a callable object.
The connection goes deeper as well. There's a style of programming called "continuation-passing style", in which nothing ever returns -- every function is passed another function to be called with its result. In a language such as Scheme that supports tail calls, you can use this style extensively without fear of overflowing the call stack.
You're using this style whenever you chain callbacks together using Futures or Deferreds. The callbacks don't return values; instead, each callback arranges for another callback to be called, passing it the result.
There is a really nice Microsoft Research called "Cooperative Task Management without Manual Stackless Management."[1] In this paper, the authors introduce the term "stack ripping" to describe how asynchronous events with callbacks handle memory. I think this is a nice way to describe the fundamental differences between continuations and Twisted callbacks/deferred. Cheers, Andrew [1] http://research.microsoft.com/apps/pubs/default.aspx?id=74219