Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rb_intern 1

Status
Not open for further replies.

stillflame

Programmer
Jan 12, 2001
416
0
0
well, this is probly more than any of you have tried to do with ruby yet, but i'll ask anyway.

i'm working on a c extension for ruby (doing a ruby version of perl's Lingua::LinkParser, for anyone who cares), and i'm unsure about how to use the api fuctions 'funcall' and 'rb_intern'. i know i can just use 'rb_eval_string' and be done with it, but i wanted to make this a little bit more efficient.

the question:

you call funcall like this -
funcall(object, method_id, argc, ...)


to get the method_id, you use rb_intern like this -
rb_intern("method_name")


but, since there are many different objects with methods that have the same name, do you have to include the class name with the method name like: "Class.method", or what?

i don't know, and i'm still a little scared to even compile any of my extension code.. i am working on a test extension to try and figure out how it works, so if you don't know the answer immediately after you're finished reading this (or before then), don't do ANY work to try and figure it out. i'm just asking this to save myself the work of writing out the (admittedly very simple) tests...

if noone else answers this before i figure it out, i'll post my answer.

thanks "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
well, i saw a few code examples (in ruby-talk) that show that it's okay to just use the method name (eg 'inspect') with any object, and that ruby figures out the rest. if you do put the Class before it, it only works if it's a class method... "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top