From: Jacob Fugal Date: 2005-07-20T03:31:07+09:00 Subject: Re: Instance Eval of a Proc On 7/19/05, Daniel Brockman wrote: > "Ara.T.Howard" writes: > > > the behaviour of Foo.method(:show_name) does exactly as > > advertised - binding the method to the class Foo along > > with that notion of self and instance vars. > > That is not in dispute. > > > so the binding of self for the duration of instance_eval > > is definitely working > > Wait, wait, wait... timeout! > > Isn't the whole point of 'instance_eval' to change the > binding of 'self'? Indeed. "Fighting ri with ri", we have from ri Object#instance_eval: Evaluates a string containing Ruby source code, or the given block, within the context of the receiver (_obj_). In order to set the context, the variable +self+ is set to _obj_ while the code is executing, giving the code access to _obj_'s instance variables. So, according to documentation, instance_eval should set +self+ to _obj_ while the code is executing. However, this binding doesn't happen if there's already a binding for self. Question is, should it? If so, there's a bug. If not, the documentation needs to reflect that. Jacob Fugal