Forum: Ruby Getting current context (from C)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
gga (Guest)
on 2007-01-06 20:30
(Received via mailing list)
I have a C function that I would like it to either be allowed to
receive a proc, method or a symbol.
In case a symbol is received, I would like that symbol to be converted
to a proc (by calling method() in the context of the *caller* to my

In pseudo-ruby code:

# the idea here is to have:
#     myfunc( :hello )
# be the same as doing:
#     myfunc( method( :hello ) )

def hello
   p 'callback'

def myfunc( proc )
    proc = stacktrace[-2].class.method( proc ) if proc.is_a? Symbol
    # .... etc ...

myfunc( :hello )    # instead of myfunc( method( :hello ) )

Can anyone point me a way to do the above in C (or even ruby)?  I'm
basically stumped on how can I call the method() function in the
context of the caller to my function, so as to properly resolve the
This topic is locked and can not be replied to.