Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Continuations in Ruby

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

like image 713
Jeff Waltzer Avatar asked Sep 29 '08 16:09

Jeff Waltzer


2 Answers

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.

like image 72
Krzysiek Goj Avatar answered Sep 22 '22 17:09

Krzysiek Goj


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.

like image 42
webmat Avatar answered Sep 19 '22 17:09

webmat