From: matz@... (Yukihiro Matsumoto) Date: 2004-07-24T15:01:10+09:00 Subject: Re: Bug? String interpolation and continuations Hi, In message "Bug? String interpolation and continuations" on 04/07/22, Sam McCall writes: |The following gives me weird results: |(Typed into IRB. The results are similar in ruby but because of the |simple example you get an infinite loop) It's not a bug. It's a feature. |# Allow a continuation to escape |store_cont = proc {|cont| $cont=cont; nil} | |puts "[#{callcc &store_cont}]" |# prints '[]', as expected saves the continuation to $cont, then evaluate "[#{nil}]". |$cont.call("hello") |# prints '[]hello]hello]hello]...' |# expected '[hello]' By calling the continuation the execution goes back to the saved point, but no other states are restored, so that the value of generating string (referenced from the local variable) remains the last generated value after the jump. Then execution concatenate "hello", then "]". Repeat forever. That's what happened. matz.