Ruby Forum Ruby-core > Continuation && Array#sort!

Posted by ts (Guest)
on 07.05.2008 12:36
(Received via mailing list)
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