From: nobu.nokada@... Date: 2002-08-14T08:23:08+09:00 Subject: Re: Is There an Inverse of 'rb_define_method'? Hi, At Tue, 13 Aug 2002 02:08:14 +0900, William Djaja Tjokroaminata wrote: > Well, I have not digged too deep into the Ruby C source code; however, to > me the answer for the dynamic arguments should be from C variable number > of arguments. It's done at compile time, but not run time. Only you can be sure that a method is callable in a particular form, when the function signature is known exactly. > I don't know the exact internal of Ruby, but to me, when parsing a Ruby > script, I guess the "rb_define_method" is called with argc either equal to > -1 or -2. Therefore, if I know that all the C functions are derived like > this, there is no problem for me to call the C functions directly: if all > are -1, then the function is of the form "func (int argc, VALUE *argc, > VALUE self)", and if all are -2, then the function is of the form "func > (VALUE self, VALUE args)". However, there are many other functions with non-negative arity, "func(self, arg1)", "func(self, arg1, arg2)" and so on. To invoke C function corresponding to ruby method, you must distinguish them, and call_cfunc() does it. And a user can redefine methods, then the methods don't have corresponding C functions. -- Nobu Nakada