George Ogata wrote:
> 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.)
> 
> 
> 
Thanks for the information.  I still can't seem to get the syntax right 
for calling Math.sin from an extension.  I can do fine by calling 
sin(RFLOAT(obj)->value).  But I'm not calling the Math module.  Just how 
does one incorporate the Math module.
One of the big problems I have is that I can't find any documentation of 
the Math module at
http://www.ruby-doc.org/doxygen/1.8.2/modules.html
Can some one give a short description of how you call math_sin from an 
extension written in C ?
What are the necessary calls?

Thanks,
Ernie