On 10/27/06, Joe Ruby MUDCRAP-CE <joeat303 / yahoo.com> wrote: > - Continuations may be planned for a future release of Ruby. > > If anybody can elaborate/correct, please feel free! Also, how would each > be useful? > Continuations represent "the rest of the computation". Try googling continuations and continuation passing style. Here's an example of how closures and continuations are useful, cooperative threading: # threading.rb: class Scheduler def initialize @threads = [] end def yield callcc do |continuation| @threads << continuation schedule end end def spawn callcc do |continuation| @threads << continuation yield schedule end end def schedule return if @threads.empty? @threads.shift.call end end def thread yield Scheduler.new end if $0 == __FILE__ puts "Testing spawning and stuff..." thread { |scheduler| puts "In parent" scheduler.spawn { puts "In child" scheduler.yield puts "In child again" } puts "In parent again" scheduler.yield } end $ ruby threading.rb Testing spawning and stuff... In parent In child In parent again In child again > Thanks, > Joe > > -- > Posted via http://www.ruby-forum.com/. > > -- - Simen