[Python-Dev] functional continuations

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Dec 15 23:54:10 CET 2007

tomer filiba wrote:
> the idea i came up with is, using exceptions for functional
> continuations: after all, the exception's traceback holds the entire
> context...

The problem with this is that, if the call chain has passed
through a C-implemented function at some point, the traceback
*doesn't* contain the entire context -- some of it is in the
C stack frames that got unwound during the propagation of
the exception.

So you may be able to make this work where all the code
involved is pure Python, but it can't work in general,
unless you redesign the whole interpreter the way the
original Stackless did.

Having said that, it might still be a useful thing to
have, as the pure-Python case is probably fairly common.
But I'd want to know what the failure mode is like when
the pure-Python case doesn't hold. Do you get a clear
indication of what is wrong, or does it misbehave in
some obscure way?

A test case for this would be to call map() with a
function that tries to suspend itself using this
mechanism. What happens when you try to resume it?


More information about the Python-Dev mailing list