In article <pan.2003.04.24.21.30.41.715600 / sneakemail.com>, Simon Strandgaard <0bz63fz3m1qt3001 / sneakemail.com> wrote: >On Thu, 24 Apr 2003 19:29:39 +0000, Phil Tomson wrote: > >> In article <006b01c30a8e$5b24ad70$6401a8c0@MELONBALLER>, >> Chris Pine <nemo / hellotree.com> wrote: >>>Maybe I'm not understanding, but can't you just call `new' on the class you >>>want to instantiate? >>> >> I want to call 'new' on the class on the C side. The more I think about >> it, the more I doubt this is possible. > > >Its possible, I do it myself all the time. > > char *name_of_class = "test"; > VALUE klass = rb_const_get(rb_cObject, rb_intern(name_of_class)); > > // (a) > //VALUE self = rb_class_new_instance(n, argv, klass); > > // (b) > VALUE self = rb_funcall2(klass, rb_intern("new"), n, argv); > > >As you can see there is two ways to instantiate (a) or (b). > Thanks. There's also a third way using rb_eval_string. Now I see how you can use rb_funcall to instantiate a new object (use rb_const_get). Phil