AlkantarClanX12
Current Path : /opt/alt/ruby18/share/ri/1.8/system/Continuation/ |
Current File : //opt/alt/ruby18/share/ri/1.8/system/Continuation/cdesc-Continuation.yaml |
--- !ruby/object:RI::ClassDescription attributes: [] class_methods: [] comment: - !ruby/struct:SM::Flow::P body: Continuation objects are generated by <tt>Kernel#callcc</tt>. They hold a return address and execution context, allowing a nonlocal return to the end of the <tt>callcc</tt> block from anywhere within a program. Continuations are somewhat analogous to a structured version of C's <tt>setjmp/longjmp</tt> (although they contain more state, so you might consider them closer to threads). - !ruby/struct:SM::Flow::P body: "For instance:" - !ruby/struct:SM::Flow::VERB body: " arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]\n callcc{|$cc|}\n puts(message = arr.shift)\n $cc.call unless message =~ /Max/\n" - !ruby/struct:SM::Flow::P body: <em>produces:</em> - !ruby/struct:SM::Flow::VERB body: " Freddie\n Herbie\n Ron\n Max\n" - !ruby/struct:SM::Flow::P body: "This (somewhat contrived) example allows the inner loop to abandon processing early:" - !ruby/struct:SM::Flow::VERB body: " callcc {|cont|\n for i in 0..4\n print "\\n#{i}: "\n for j in i*5...(i+1)*5\n cont.call() if j == 17\n printf "%3d", j\n end\n end\n }\n print "\\n"\n" - !ruby/struct:SM::Flow::P body: <em>produces:</em> - !ruby/struct:SM::Flow::VERB body: " 0: 0 1 2 3 4\n 1: 5 6 7 8 9\n 2: 10 11 12 13 14\n 3: 15 16\n" constants: [] full_name: Continuation includes: [] instance_methods: - !ruby/object:RI::MethodSummary name: "[]" - !ruby/object:RI::MethodSummary name: call name: Continuation superclass: Object