views:

55

answers:

2

There are many continuation based framework for java, ruby etc but none in python. Nagare framework somewhat solves the problem but it do not use standard python and uses stackless python to solve continuation problem.

I was wondering,

what part of standard python constraint to create such continuation web framework in standard python ?

and What are the workaround to it ? and what are standard part in continuation framework architecture ( as model view controller are in MVC ) ?

+2  A: 

Before you can even begin to consider writing a continuation based framework you need a programming language that has continuations (or at least co-routines which can be used to emulate continuations). Continuation is a control structure like loops or closures or functions, not a design pattern like MVC. Unfortunately the (currently) standard Python does not support continuations. Which is one of the reason people developed stackless python.

Java is a bit of a special case. The language itself does not support continuations but the virtual machine does (in order to support exceptions). I think what they did was to modify the compiled bytecode at runtime and re-order instructions so that it looks like it supports continuations. Kind of like implementing stackless python by monkey-patching.

slebetman
Cpython does support coroutines though.
aaronasterling
+1  A: 

Right, continuation is a property of a language and CPython sadly has not continuations.

The workarounds in pure Python are well known : use callbacks / deferers like Twisted and Tornado for example or use 'yield' everywhere to mimic co-routines, like Diesel. But both approaches force you to change the way you design and code your application. Also a continuation can be "replayed" which is how the continuation based frameworks automatically handle the "back" button problem.

Finally, to be exact, in Nagare we are using the pickling of a freezed tasklet to obtain a continuation object.

apoirier
nagare pretty much impressed me, but I would like to use it on google app engine, are you or authors at nagare working on app engine ? I can help with testing part...
iamgopal