T
Tom Cloyd
Trying this for the first time, and, as usual, not quite getting it.
Everything I can find on kernal::binding tells me that I just call it
and will get back a binding object which can be passed in a call to
eval. But...it doesn't work for me.
In my main, I have a module required which contains a method I'm trying
to call. For reasons irrelevant to this current problem, I'm using an
eval of a string to do it, and want the method to execute in the
environment of the main program. So...
eval( "moduleName.methodName", binding)
Causes *crash* due to by attempt to access a variable which exists in
the calling environment but not in the module. In spite of passing the
binding, the method knows nothing of the variable. It's not working.
All examples I can find just do something like..
def meth_x
y = 1
return binding
end
Then 'y' is accessed using the binding. Well, if one can return a
binding to initialize a variable -
z = meth_x
eval( "y", z ) # => "1"
Then why can't I simply pass 'binding' in an eval call FROM the calling
environment?
I must be missing something, to state the obvious.
Can someone explain?
Thanks,
t.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< (e-mail address removed) >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Everything I can find on kernal::binding tells me that I just call it
and will get back a binding object which can be passed in a call to
eval. But...it doesn't work for me.
In my main, I have a module required which contains a method I'm trying
to call. For reasons irrelevant to this current problem, I'm using an
eval of a string to do it, and want the method to execute in the
environment of the main program. So...
eval( "moduleName.methodName", binding)
Causes *crash* due to by attempt to access a variable which exists in
the calling environment but not in the module. In spite of passing the
binding, the method knows nothing of the variable. It's not working.
All examples I can find just do something like..
def meth_x
y = 1
return binding
end
Then 'y' is accessed using the binding. Well, if one can return a
binding to initialize a variable -
z = meth_x
eval( "y", z ) # => "1"
Then why can't I simply pass 'binding' in an eval call FROM the calling
environment?
I must be missing something, to state the obvious.
Can someone explain?
Thanks,
t.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< (e-mail address removed) >> (email)
<< TomCloyd.com >> (website)
<< sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~