Ernest Ellingson <erne / powernav.removethis.com> writes:

> If you look at the Math_init() function it aliases the math_sin
> function in Math.c as "sin" with 1 argument.  However, (this is
> where I become confused) the math_sin function seems to require 2
> inputs not one.

In ruby, all functions -- even things that look like static member
functions like Math.sin -- are methods of an object.  Math.sin is a
method of the Math object.

Now, whenever you call a C function that's bound to a ruby method, one
parameter is always the receiver of the call -- the "self".  Nearly
always, this is the first parameter of the C function.

Combining the above two snippets of knowledge:

To call math_sin() properly, the first argument should be the receiver
of Math.sin: rb_mMath.  (If you've looked at the source though, you'll
probably realize that it doesn't really matter what you give as the
first argument since Math.sin has no need to reference it.)