Continuations, here I come

Charles Oliver Nutter headius at headius.com
Tue Jul 28 13:15:31 PDT 2009


Ok, I've decided that along with tail calls and indy, the next thing
on my list is delimited continuations.

Ruby 1.9 has started to make heavier use of "fibers", which are
basically just coroutines or generators. Not only can you use them
directly, a la fiber = Fiber.new, you can also get generator behavior
out of any method on Enumerable. So instead of writing:

foo.each {|a| p a}

you can do

enum = foo.each
p enum.next
p enum.next
...

This is implemented in CRuby by using coroutines and stack-saving
techniques. On the JVM, if we can't reduce the enumeration to a simple
case (like known core classes), or if the iteration is arbitrarily
complex (as it could be for a user-defined enumerable type), our only
option is to use a thread. And that will be pretty heavy if people are
doing a lot of enumeration.

So I need to ask:

What's the status of the continuation patch?
Who else has interest in it?
Would delimited continuations reduce security concerns?

- Charlie



More information about the mlvm-dev mailing list