Strange Loops

No Matter Where You Go, There You Are

Simple but Illuminating

| Comments

Continuations sound scary but at a basic level they are a simple construct. I’ve been thinking of them as closures that contain your entire execution context. I found the Ruby examples to be the most illuminating for me.

 def bar 3.times do |i|  callcc { |cont| return cont }  print "#{i}\n"  endend> a = foo> a.call0> a.call1> a.call2> a3

Everytime I invoked call on the returned continuation, it continued from where I had left off within the method bar. Continuations are a useful idea and it would be nice to see in more languages. Interestingly enough, the Java world seems to be warming up to the idea of continuations; Two I’ve read about recently Jetty and RIFECNT.

After understanding this concept, it’s easy to see how something like Continuation Passing Style would work.

See more progress on: understand continuations