Thomas Hafner wrote: > That's not enough. Now recursion comes into place: multiline_tail can > call itselve via the method multiline. Oh yes - sorry for being dense. So the attraction of callcc is it generates a new object each time which, when called, brings you back to exactly this level of nesting. gensym simulates the same for catch/throw. It's a limitation here that catch/throw can only use symbols, which are not garbage-collectable, so eventually you'll run out of RAM. You only need one symbol per level of recursion, so you could keep a stack of them, but that's housekeeping. What I'd suggest as a first step is to factor out the whole 'loop which can be restarted' concept. This makes it very easy to experiment with alternative implementations. Here's one from the top of my head: def restartable_loop tag = Class.new(RuntimeError) loop do begin yield tag rescue tag end end end def restart(tag) raise tag end I've attached your code with this modification, and it seems to work. However if the logic were factored out like this I would object less to the use of callcc, because I think it makes the intention much clearer. Attachments: http://www.ruby-forum.com/attachment/3224/prog3.rb -- Posted via http://www.ruby-forum.com/.