Kent Dahl wrote:
> Seeing the threads on blocks and scope, I was wondering if there is any
> way to explicitly designate a binding when calling a block or proc?
> 
> I've seen eval take a binding, but I can't seem to be able to change the
> binding of a proc. Since a proc has to remember the binding anyway, I'm
> curious as to wheter there is an easy way to change it afterwards?
[...]
> I hope that made some sense :-P

Obviously not, since there aren't any comments so far...

What I'm wonder wheter does, could or should exist, is an equivalent to

	eval stringWithRubyCode, aBindingOfMyChoice

but for Proc objects. Something like this

	def myMethod( x, &p )
		b = binding
		p.setBinding( b )
		p.call( x )       
	end

	x = 5
	z = 3
	myMethod( z ){|a| 
		puts " A:" + a.to_s +
		     " X:" + x.to_s
	}  #=> A:3 X:3

Thusly the methods local x is the one visible, as well as p itself,
instead of the variables visible where the block was defined.

Are there any particular reasons why a Proc object doesn't have
getBinding, setBinding and/or callWithExplicitBinding methods? 

One thing this could be useful for, is creating "empty" bindings, so
that calling a Proc doesn't have sideeffects on the scope where its code
was defined.

*still curious* 

-- 
<[ Kent Dahl ]>================<[ http://www.stud.ntnu.no/~kentda/ ]>
  )____(stud.techn.;ind..data)||(softwareDeveloper.at(Trustix))_( 
 /"Opinions expressed are mine and not those of my Employer,      "\
( "the University, my girlfriend, stray cats, banana fruitflies,  " )
 \"nor the frontal lobe of my left cerebral hemisphere.           "/