---259931071-1677823643-11069041116946
Content-Type: MULTIPART/MIXED; BOUNDARY="-259931071-1677823643-1106904111=:16946"

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

---259931071-1677823643-11069041116946
Content-Type: TEXT/PLAIN; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE


Thank you all for the response. :-)

I think comp.lang.ruby is a great newsgroup with friendly and 
highly competent people. I really enjoy reading the postings of my 
interesst, and that`s a lot. I spend nearly an hour reading this newsgroup 
each day, and have allready posted at least 3 mail to it myselfe.

I am missing a site for n00bs to program extending Ruby though, does there 
exist any ? I have read README.EXT and I have bought the wonderful 
Pickaxe2.

What about "extending" the Ruby exam site 
(http://www.rubygarden.org/ruby?RubyExam) with an "extending Ruby" part ?

On Fri, 28 Jan 2005, Charles Mills wrote:

> Tim Sutherland wrote:
>> In article <d4cf71b0050127093664c9bf7b / mail.gmail.com>, Lyle Johnson
> wrote:
>>> On Fri, 28 Jan 2005 01:56:24 +0900, Asbjøòn Reglund Thorsen
>>> <asbjoert / ifi.uio.no> wrote:
>>>
> (...)
>> As an alternative to rb_ary_store(), you can access the buffer
> underlying
>> the Array directly:
>>
>>     $result = rb_ary_new2(size);
>>     for (int i = 0; i < size; ++i)
>>     	RARRAY($result)->ptr[i] = rb_float_new((double) p(i+1)));
>>
>> The latter is faster since it doesn't have to check things like
>>  - 'Do we need to increase the buffer size'
>>  - 'Is the buffer shared with another Array'
>>  - 'Is the Array frozen'
>>  ...etc.
>
> There is a gotcha to this though.
> rb_ary_new2(size) returns an array with length==0 and capacity==size.
> The example you give above never increases length.
> You could fix this with
> RARRAY($result)->len = size;
> However, this is also a gotcha.  If you put it before the loop then the
> array is filled with a bunch of garabage references which will crash
> Ruby if the GC is run when rb_float_new() is called.  If you put it
> after he loop then all those floats you create could be destroyed by
> the GC, causing Ruby to crash later.
> rb_ary_store() is the simplest and safest solution.  You could also do:
>
> $result = rb_ary_new2(size);
> for ( ; RARRAY($result)->len < size; RARRAY($result)->len++) {
> int i = RARRAY($result)->len;
> RARRAY($result)->ptr[i] = rb_float_new((double) p(i+1)));
> }
>
>
> -Charlie
>
>
>
---259931071-1677823643-11069041116946--
---259931071-1677823643-11069041116946--