From: gltewalt@... (illocutionist) Date: 2004-07-23T06:07:00+09:00 Subject: Re: Bug? String interpolation and continuations Carlos wrote in message news:<20040722102042.GA1575@quovadis.com.ar>... > [Sam McCall , 2004-07-22 08.52 CEST] > > 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) > > > > ================================= > > # Allow a continuation to escape > > store_cont = proc {|cont| $cont=cont; nil} > > > > puts "[#{callcc &store_cont}]" > > # prints '[]', as expected > > > > $cont.call("hello") > > # prints '[]hello]' > > # expected '[hello]' > > My guess is, the line with the puts and the interpolated string is > internally translated to something like: > > s = "[" > s << callcc &store_cont > s << "]" > > puts s > > -- This doesnt address your problem fully, but you can do: puts "[#{callcc &store_cont}" + "]" $cont.call("hello") # [hello] # => nil