Thomas Hafner wrote:
> Hello,
> 
> in his book ``The Ruby Programming Language'' Mats discourages from
> using continuations. Nevertheless I've found a real world example,
> where at a first look callcc could be easily replaced by catch and
> throw, but indeed it's a little bit problematic:

In an almost totally unrelated vein, I just committed support for 
"one-shot downward continuations" to JRuby. Essentially it allows you to 
use callcc in JRuby as long as the continuation doesn't escape the 
original block activation:

puts callcc {|cc| cc.call('ok!')} #=> ok!

Or...

def foo(cc); cc.call('ok!'); end
puts callcc {|cc| foo(cc)} #=> ok!

But...

x = callcc {|cc| cc}
x.call #=> -e:1:in `call': continuations can not be called from outside 
their scope (LocalJumpError)

Thanks go to Evan Phoenix for pointing out that this limited case is 
easy to support, even in JRuby. I don't know if anyone ever uses this, 
but it works now.

Perhaps even as a replacement for catch/throw? (Hey, now I'm on topic!)

- Charlie