From: David Landrith Date: 2003-03-25T12:50:08+09:00 Subject: Re: Writing a new method in C for a subclass > If you're trying to do something very deep, which involves fudging > with the > implementation of Array itself, rather than just adding methods to > Array, > then I'm out of my depth :-) > > It does seem to me that whatever you write is going to be heavily tied > to > the particular implementation of Array which exists now, and therefore > may > not be very portable. Without knowing what you're trying to achieve, > would > be it be worth using 'has_a' instead of 'is_a'? That is, create a new > object > which in turn contains an instance of an Array? You can then > mechanically > delegate to it. I'm not sure that what I am trying to do is very complicated, and I certainly don't want to tie it to any specific implementation of Array. I know that I'm not doing a great job of explaining this, but I have not sensed that there is a specific lingo that I am supposed to be using to describe how the C extension API works with any real granularity. If I am wrong about this, I'd like a few pointers on where to look to become more familiar with it. At any rate, let my try to explain again: If I want to make a new Array in c, I can type rb_ary_new2(long int) -- or rb_ary_new() which calls it -- in my c program/extension, and one may look at implementation of these methods in array.c. So suppose I want to create a class that extends Array then instantiate it in c. If I do this, then I must have a function -- say myArray_new() -- in C that wraps up a structure and returns a pointer to it much like rb_ary_new2(long int). Are there any special requirements for myArray_new to make sure that it's values are accessible by the methods of its superclass? Do I need to somehow include a pointer the the rb_cArray object or the RArray struct in the struct used by myArray? Or do I simply make a struct for myArray that is a superset of the values in the RArray struct and let the "define_class" method handle the details? Does this make sense? ------------------------------------------------------- David King Landrith (w) 617.227.4469x213 (h) 617.696.7133 One useless man is a disgrace, two are called a law firm, and three or more become a congress -- John Adams ------------------------------------------------------- public key available upon request