On 3/12/07, Daniel Berger <djberg96 / gmail.com> wrote:
> On Mar 12, 4:02 pm, "Jan Svitok" <jan.svi... / gmail.com> wrote:

> > Second run without assignments:
> >
> > W:\projects\ruby\ruby\ruby-1.8.6\win32>bench_collect.rb
> >                                     user     system      total        real
> > Array#collect                   6.875000   0.047000   6.922000 (  6.953000)
> > Array#acollect
> > W:/projects/ruby/ruby/ruby-1.8.6/win32/bench_collect.rb:17: [BUG]
> > cross-thread violation on rb_thread_schedule()
> > ruby 1.8.6 (2007-03-13) [i386-mswin32_80]
>
> Ouch. I had a feeling it would collapse. Maybe wrapping the relevant
> code in RUBY_CRITICAL would work, but that may defeat the purpose,
> assuming it even works at all.

Even if it worked it would have some other problems. If the block
argument was at all sensitive to evaluation order, for example, the
results would be indeterminate I think.

For a cooked up example:

i = 0
(1..100).to_a.acollect {|elem| i += 1}

Interaction with the GC might also be interesting.

-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/