From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-04-08T02:49:23+09:00 Subject: Re: [embedding] keeping track of non-exported global variables On Sat, 05 Apr 2003 23:19:15 +0900, ts wrote: >>>>>> "S" == Simon Strandgaard <0bz63fz3m1qt3001@sneakemail.com> writes: > S> On the section of registering/unregistering global objects, > S> what should I write: Either that people should use an array > S> because this is what pickaxe says. Or that they should use a > S> hash because this is what [mod_ruby, vim, ruby++] uses. > > Just say that they can use an Hash or an Array : after if someone think > that it's easier (or faster) to manage an Hash (or an Array) he can do > what he want. > > S> Why does mod_ruby use a hash? why not array? > > Good question :-) > > Probably only the author of mod_ruby know the response :-) I tried mailing Shugo Maeda, but I haven't got any replys.. hmmm maybe I should another of his mailing adresses? Arrays works fine for me, but im still wondering why both mod_ruby, vim, ruby++ uses hashes ??? It seems odd. Objects::Objects() { objects = rb_ary_new(); rb_global_variable(&objects); } Objects::~Objects() { /* flush array in order to kill em I do not think this is necessary at all. I am assuming that calling ruby_finalize() would effectivly kill all! todo: is flushing necessary? */ } void Objects::Register(VALUE object) { cout << "objects += " << hex << object << endl; rb_ary_push(objects, object); } void Objects::Unregister(VALUE object) { cout << "objects -= " << hex << object << endl; rb_ary_delete(objects, object); }