Exception feature creep! (was: re-entering in the normal flow after an exception is raised)

Paul Rubin http
Fri Oct 1 23:34:34 EDT 2004


michele.simionato at gmail.com (Michele Simionato) writes:
> Nevertheless, it is possible that if we had resumable exceptions we 
> could use them as a control flow structure in non-exceptional situations.
> One could speculate about the idea ...

Sure.  You could raise a resumable exception whose handler runs some
code before resuming after the exception.  The handling code could do
some stuff that raises its own resumable exception.  Now you have two
resumable exceptions pending, and it would be cool if you could resume
the first one before resuming the second.  In fact what you'd really
like is a "resumption" object created by raising the exception, that
you can pass control to at any time, sort of like yielding from a
generator.  Maybe you're getting deja vu now, since this is basically
what Stackless Python continuations were.  They give you a simple way
to implement coroutines and just about anything else you could want.



More information about the Python-list mailing list