From: Mat Schaffer Date: 2006-06-17T03:28:05+09:00 Subject: Re: More rebinding blocks On Jun 16, 2006, at 12:56 PM, Logan Capaldo wrote: > On Jun 16, 2006, at 12:46 PM, Mat Schaffer wrote: > >> Sorry to beat a dead horse, here. But after reading through the >> older discussions on google groups, I'm still left with a question. >> >> Arbitrarily rebinding blocks seems like it would be amazingly >> useful. Is there some fundamental reason that the following code >> is impossible? Or has it just not been implemented yet. >> >> class MyClass >> def runhere(b) >> @a = 3 >> b.binding = self.binding >> b.call >> end >> end >> >> MyClass.new.runhere(proc { puts @a }) > > 1.9 has #instance_exec which is #instance_eval + the ability to > pass args. (The urge for me to actually check out 1.9 grows daily.) Oh nice. That would work. It doesn't exactly answer my question, though. But I guess the answer could just be that the community didn't decide on that particular syntax. Can Matz or anyone offer any assurance that that feature of 1.9 will survive in later releases? I'd hate to write code that uses it only to loose it in a future release. Thanks, Mat