On Thu, Apr 25, 2002 at 08:49:46AM +0900, Richard P. Groenewegen wrote: > But is there a way to do it without rb_eval_string (and with > rb_funcall or whatever)? VALUE rb_cPoint = rb_const_get(rb_cObject, rb_intern("Point")); return rb_funcall(rb_cPoint, rb_intern("new"), INT2NUM(3), INT2NUM(4)); or equivalently: VALUE args[] = { INT2NUM(3), INT2NUM(4) }; return rb_class_new_instance(2, args, rb_cPoint); > Additional question: Currently I have an empty init function (it just > returns self), which I do bind to "initialize" in Init_Curve and I > also call rb_obj_call_init from curve_init. > > - Is it necessary to call rb_obj_call_init even though my init > function is empty? No, this is done by rb_class_new_instance. > - Is it necessary to define the init function at all? Not if it doesn't do anything. And it need not return self; the return value is ignored. > Even more questions: I am rewriting a couple of ruby extensions > (written in ruby) in C and I'm doing this one module at a time. Let's > say I have files called a.rb, b.rb, c.rb, where each file requires the > previous file. When writing a.c, b.c, c.c would you use > > rb_require("b.so"); > > in c.c or would you use a and b somehow on the C-level? I usually implement just core functions in my C extensions, and have a Ruby script that does the requiring. This makes documenting my code easier, since I can put all the documentation in the Ruby script. There's probably a better way to do it, though. Paul