From: Ruby Talk Date: 2008-05-03T02:26:53+09:00 Subject: Re: Is there some way to execute a block within an arbitrary lexical scope? Robert, Well, let's say that that something is a new class I want to define within that scope. And I'd like the innards of that class to be able to take advantage of the the natural, idiomatic lookup rules, where the interpreter traipses up the ancestor chain. To be more clear, let's say I have X = :bad module A X = :good class B #...let us say I want to execute something here where X == :good end end And I'd like to execute something from outside that lexical scope (let's say from my metaprogramming classes) within that [A, A::B] lexical scope. I guess what I'm asking is: is there any way of faking lexical scope (for the purposes of metaprogramming)? Robert Klemme wrote: > 2008/5/2 ara.t.howard : > >> On May 1, 2008, at 3:31 PM, Ruby Talk wrote: >> >> >>> Let's say I'm doing some metaprogramming from another class and I want to >>> >> do something in B's full lexical class scope. >> > > What exactly is this "something"? > > >> then you will need to use continuations. >> > > It depends of course what should be achieved. A simple constant > lookup is easily done via #const_get. Other things can be achieved > via #instance_eval. > > Cheers > > robert > >