From: ts Date: 2001-06-27T00:04:30+09:00 Subject: [ruby-talk:16905] Re: rb_define_method when argc is -1 >>>>> "L" == Laurent Julliard writes: L> I have a piece of code under my eyes where rb_define_method is called L> with the argc parameter at -1. Is this a documented feature of the L> function and if so what does it do exactly ? See README.EXT 2.1.2 Method/singleton method definition To define methods or singleton methods, use functions below: void rb_define_method(VALUE klass, const char *name, VALUE (*func)(), int argc) void rb_define_singleton_method(VALUE object, const char *name, VALUE (*func)(), int argc) The `argc' represents the number of the arguments to the C function, which must be less than 17. But I believe you don't need that much. :-) If `argc' is negative, it specifies calling sequence, not number of the arguments. If argc is -1, the function will be called like: VALUE func(int argc, VALUE *argv, VALUE obj) where argc is the actual number of arguments, argv is the C array of the arguments, and obj is the receiver. if argc is -2, the arguments are passed in Ruby array. The function will be called like: VALUE func(VALUE obj, VALUE args) where obj is the receiver, and args is the Ruby array containing actual arguments. Guy Decoux