From: William Djaja Tjokroaminata Date: 2002-09-25T23:43:01+09:00 Subject: Re: Object-Oriented struct Model in C Paul Brannan wrote: > You don't really need references to all the inner the objects on the > stack; you could have a reference to an object that holds references to > all your inner objects. But at any level, if that object that holds references to the inner objects was not created using Data_Wrap_Struct(), there is no way for it to mark the inner objects, is there? > An array of VALUES allocated with ALLOCA would work, as long as it is > aligned properly on the stack. This uses more stack space than a Ruby > Array, but is cheaper to construct. Very good point, Paul. > Also note that if you have a structure like this: > +-A > Top--| > +-B--+-C > | > +-D > Then you only need to keep references C and D on the stack while > registering B; you only need to keep references to A and B while > registering Top (since C and D are already referred to by B). Actually, what is the meaning of "registering B"? Is it rb_gc_register_address()? I am assuming here only the Top object is created using Data_Wrap_Struct(). (If we use rb_gc_register_address(), doesn't it mean that we don't need any mark function? We then just need to rb_gc_unregister_address() when the C destructor is called.) Regards, Bill