# Getting current context (from C)

**URL:** <https://www.ruby-forum.com/t/getting-current-context-from-c/81221>\
**Category:** Ruby\
**Created:** [January 6, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/getting-current-context-from-c/81221 "2007-01-06T19:30:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b487fb/32.png) [@gga](https://www.ruby-forum.com/u/gga)\
**Post date:** [January 6, 2007, 7:30pm UTC](https://www.ruby-forum.com/t/getting-current-context-from-c/81221/1 "2007-01-06T19:30:21Z")

</div>

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  
method).

In pseudo-ruby code:

# the idea here is to have:

# myfunc( :hello )

# be the same as doing:

# myfunc( method( :hello ) )

def hello  
p ‘callback’  
end

def myfunc( proc )  
proc = stacktrace[-2].class.method( proc ) if proc.is\_a? Symbol  
# … etc …  
end

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  
binding.
