abusing exceptions for continuations

G

gangesmaster

i've had this strange idea of using the exception's traceback (which
holds the stack frame) to enable functional continuations, meaning,
raise some special exception which will be caught by a reactor/
scheduler/framework, which could later revive it by restoring the
frame.

i'm thinking of using the generator's implementation (some minimal
support on the c-side)

has this been tried before? what were the results?


thanks,
-tomer
 
B

Bruno Desthuilliers

gangesmaster a écrit :
i've had this strange idea of using the exception's traceback (which
holds the stack frame) to enable functional continuations, meaning,
raise some special exception which will be caught by a reactor/
scheduler/framework, which could later revive it by restoring the
frame.

i'm thinking of using the generator's implementation (some minimal
support on the c-side)

has this been tried before? what were the results?

I don't know, but you may want to have a look at Stackless Python.
 
P

Paul McGuire

i've had this strange idea of using the exception's traceback (which
holds the stack frame) to enable functional continuations, meaning,
raise some special exception which will be caught by a reactor/
scheduler/framework, which could later revive it by restoring the
frame.

i'm thinking of using the generator's implementation (some minimal
support on the c-side)

has this been tried before? what were the results?

thanks,
-tomer

Simpy has a mechanism like this, for discrete event simulation
modeling of processes and resources. Processes "run" for a while,
then yield a delay or a hold on a resource, and are resumed later.

-- Paul
 
L

Lautaro Pecile

i've had this strange idea of using the exception's traceback (which
holds the stack frame) to enable functional continuations, meaning,
raise some special exception which will be caught by a reactor/
scheduler/framework, which could later revive it by restoring the
frame.

i'm thinking of using the generator's implementation (some minimal
support on the c-side)

has this been tried before? what were the results?

thanks,
-tomer

That idea has been tried here http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/474088

It fails with algorithms which not use tail call recursion, and is
veeery slow. Try with Stackless.

Lautaro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top