ts | 7 May 12:31
Picon
Picon

[1.9] Continuation && Array#sort!


 The example came from test/ruby/test_continuation.rb

vgs% cat b.rb
require 'continuation'
n = 1000
ary = (1..100).to_a
ary.sort! {|a,b|
   callcc {|k| $k = k } if !defined? $k
   if ary.size != 100
      puts "#{n} #{ary.size}"
      exit
   end
   a <=> b
}
n -= 1
$k.call if 0 < n
vgs% 

vgs% ./ruby -v b.rb
ruby 1.9.0 (2008-05-07 revision 16311) [i686-linux]
998 15
vgs% 

 If you remove 'exit' it will segfault.

 Look what it do with tmp in rb_ary_sort_bang()

Guy Decoux

(Continue reading)


Gmane