From: Michael Neumann Date: 2008-10-31T03:15:30+09:00 Subject: [ruby-core:19636] Re: Future of Continuations r. schempp schrieb: > Hi, > > In my master thesis I dealt with Continuations Based Web Servers and > tried to use continuations in Rails. This didn't go very well. I > expected continuations to work like I knew from their definition, but > they don't restore state in Ruby (1.8.6). Further the use of > continuations is limited to the thread they are created in. This seems > to be caused by implementing continuations with threads. Hi, Interesting. I implemented a Seaside-like framework with a lot of help of Avi Bryant (the author of Seaside), called Wee [1]. From my experience, continuations *do* work. But under certain (rare) situations, they leak memory. I think this is due to conservative garbage collection. Continuations do not restore state!!! They restore the execution context (the stack), but never, ever the heap. Restoration of state in Wee is implemented using explicit state marshalling for the purpose of backtracking. Important to note is that you have to save the content of the objects and restore back to existing (!) objects (those that are references from within the continuation/execution context) with this marshalled content (i.e. str.replace(backtracked_copy) instead of str = backtracked_copy.dup), otherwise continuations won't work. Another thing to note is that it is very advantages when using continuations to have a very small-sized stack and not something as big as Rails, otherwise you run into memory problems. Regards, Michael [1]: http://www.rubyforge.org/projects/wee > > I know continuations are much discussed, but I don't want to go in > this topic very deep here. My concern is to bring back into mind that > continuations are a very helpful programming tool for special topics > like Continuation Based Web Server. > > Maybe you know Seaside (a Continuation Based Web Server in Smalltalk), > which uses Continuations to support state and a linear kind of control > flow in web applications. To my mind Ruby should, as a web programming > language, offer continuations without their current limitations. > > I'd be happy if you would consider this attempt I your future thoughts > about developing Ruby. And I'd love to see continuations implemented > in future Ruby versions. > > Thanks & regards > Ruben > >