views:

1110

answers:

4

Has anyone ever done work to get Ruby to do continuations (like Seaside on Smalltalk)?

+10  A: 

Yes, in most cases. MRI (1.8) have supported them as far as my memory reaches, Ruby 1.9 (YARV) does it, too, so does Rubinius. JRuby and IronRuby don't have continuations, and it's quite unlikely they will get them (JVM and CLR use stack-instrospection for security)

Ruby as a language supports continuations via callcc keyword. They're used, for example, to implement Generator class from standard library.

continuations on ruby-doc

Continuation-based web frameworks (like seaside, or one from Arc's std. library) seem less popular. I've found wee that claim to let you do optional continuations, but I've never used it.

Krzysiek Goj
+6  A: 

As others have said already, Ruby 1.8 supports continuations.

Ruby 1.9 has not supported them for a while however. They have been added back some time this year, but most of the other Ruby interpreters (JRuby, IronRuby, etc) don't support them.

If you want your code to be usable on other platforms than the mainline Ruby, I'd suggest not using them.

Read this InfoQ article for a more comprehensive discussion on the topic.

webmat
+1  A: 

neverblock uses 1.9 fibers for a single threaded ruby web server

rogerdpack
A: 

Btw this is an example of restartable exceptions (aka conditions) implemented using continuations. I used it few times and it's a cool thing to have in a Ruby toolbox.

Wojciech Kaczmarek