From: Ken Bloom Date: 2007-12-31T13:10:00+09:00 Subject: Re: Using "sort!" in a C extension (1.9 problem) On Sat, 29 Dec 2007 23:15:19 -0500, KUBO Takehiro wrote: > On Dec 30, 2007 12:11 PM, Andre Nathan wrote: >> On Sun, 2007-12-30 at 11:36 +0900, Andre Nathan wrote: >> > On Sun, 2007-12-30 at 10:59 +0900, KUBO Takehiro wrote: >> > > Use rb_ary_sort_bang instead of call_sort_bang. I don't know why >> > > call_sort_bang doesn't work. > > Sorry. This is my mistake. > >> but that has the same problem I had with rb_funcall -- sort_by_length >> is given the current array element only as its argument. > > How about the following patch to ruby svn trunk? > > --- vm_insnhelper.c (revision 14790) > +++ vm_insnhelper.c (working copy) > @@ -652,9 +652,12 @@ > else if (argc == 0) { > arg = Qnil; > } > - else { > + else if (argc == 1) { > arg = argv[0]; > } > + else { > + arg = rb_ary_new4(argc, argv); > + } > > vm_push_frame(th, 0, FRAME_MAGIC_IFUNC, > self, (VALUE)block->dfp, > > I'm not certain this is a correct patch. But at least, sort_by_length > works fine. Was this a bug that needs to be patched, or an intentional change from Ruby 1.8 to Ruby 1.9? I thought it was the later. --Ken -- Ken (Chanoch) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/