Forcing a BlockContext to evaluate in current context -djb
lex at cc.gatech.edu
Sun Feb 9 13:55:57 UTC 2003
Derek Brans <brans at nerdonawire.com> wrote:
> I want to force a block to evaluate in the current context. How is this
> [self class] valueInCurrentContext
> returns the class of the object that called "valueInCurrentContext"
There may be a cleaner way. This is going to lead to code that has
landmines. For example, a refactoring browser (or a refactoring human)
will happily do "extract method" on code such as this and move the code
to a different method and even a different class, but it would break the
meaning of the code. Also, it breaks the ability to do indirect calls,
where the real sender (in some sense) invokes an intermediate helper
method, which in turn invokes the raw block. It's fairly fundamental
that methods cannot ask who invoked them (this is useful, because it
makes methods definitely behave the same no matter where they are called
What are you trying to accomplish? Are you trying to pick up variables
from the caller, or just the caller object itself ?
Oh yeah, one other thing is that if you *really* call a block from a
different context, you will probably lose the dynamic safety that the VM
normally gives you, such as that all variables will exist when you try
to read them. Adding the checks back adds some extra complexity.
More information about the Squeak-dev