At Thu, 25 Oct 2001 22:49:12 +0900,
Paul Brannan <pbrannan / atdesk.com> wrote:
> 1) rb_thread_select and rb_thread_wait_for take ANYARGS, but passing just
> any old arguments to these functions is likely to crash your program.  I
> once had a case where I accidentally passed the wrong type for the timeval
> parameter, and it took me a while to figure out what was going on.
> Changing these to use the correct arguments in the header does not appear
> to break anything (at least in 1.6.5).

The correct prototypes for rb_thread_select() and
rb_thread_wait_for() use `fd_set' and `struct timeval'. And I
didn't want to force to include system dependent headers.


> 2) A less important issue, rb_define_method and friends take ANYARGS, but
> I don't think it's ever legal for these functions to ever take a method
> that doesn't have at least one VALUE parameter for self (so they should
> take VALUE(*)__(VALUE, ...).

Not all methods take `self' first.  Consider -1 arity methods.
Rather, I suggest;

#ifdef __cplusplus
inline void rb_define_method(VALUE klass, const char *name,
			     VALUE (*func)(int, VALUE*, VALUE))
{
    rb_define_method(klass, name, (RUBY_METHOD_FUNC)func, -1);
}

inline void rb_define_method(VALUE klass, const char *name,
			     VALUE (*func)(int, VALUE*))
{
    rb_define_method(klass, name, (RUBY_METHOD_FUNC)func, -1);
}

inline void rb_define_method(VALUE klass, const char *name,
			     VALUE (*func)(VALUE))
{
    rb_define_method(klass, name, (RUBY_METHOD_FUNC)func, 0);
}

inline void rb_define_method(VALUE klass, const char *name,
			     VALUE (*func)(VALUE, VALUE))
{
    rb_define_method(klass, name, (RUBY_METHOD_FUNC)func, 1);
}

// ... and so on
#endif


> 3) I think there could be similar issues as #2 for rb_iterate, rb_rescue,
> etc.

They can be prototyped, maybe.


> 4) rb_protect_inspect still takes a VALUE(*)().

Yes, it's a mistake.


Nobu Nakada