From: David King Landrith Date: 2003-03-25T05:21:05+09:00 Subject: Re: Writing a new method in C for a subclass On Monday, March 24, 2003, at 11:30 AM, Brian Candler wrote: > On Tue, Mar 25, 2003 at 01:07:40AM +0900, David Landrith wrote: >> Unless all inheritance is handled by rb_define_class > > Yes you should be able to subclass Array directly. Try: > > rb_cMyArray = rb_define_class("MyArray", rb_cArray); > > which I understand to be the same as > > MyArray = Class.new(Array) > or > class MyArray < Array > end This much I understand. This is a complicated topic, and it looks like what I wrote before was rather convoluted. If anyone is able to restate what I'm trying to ask in a more straightforward manner, I'd appreciate it. I am wondering if there is anything special that I must do to create a method that instantiates a new MyArray object in c. All of the examples of "new" methods (meaning a methods that are declared using the form rb_define_singleton_method(myClass, "new", myClass_new, argc) simply extend rb_cObj. I know that if I extend the Array, then I will create a class whose objects will have the same set of values as Array. It seems that in order to define a class from the ground up (meaning including the "new" method), you need to create a struct, wrap it, and return the VALUE pointing to the wrap. I can do this easily enough, but if I am extending a class, do I create a struct that points to the super class? or do I create a struct that contains all of the values in the superclass? or am I on entirely the wrong track? ------------------------------------------------------- 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