Nothing for the faint-hearted. This package is a VM modification which allows
arbitrary objects to 'act' like CompiledMethods. In other words, if you want
to have some object to act like a method you merely add it to the appropriate
method dictionary, like in:
Object addSelector: #foo:bar: withMethod: FooBarAlgorithm.
When you now say something like:
someObject foo: 42 bar: 'mumble'.
the special message #run:with:in: will be sent to FooBarAlgorithm so you could
handle it like this:
FooBarAlgorithm class>>run: originalSelector with: argsArray in: aReceiver
"Run the FooBarAlgorithm when invoked via originalSelector from aReceiver.
argsArray contains the arguments passed along with the original invokation."
Pretty cool, eh? Needless to say, the package requires a new VM. Without it,
the supplied tests will horribly crash your system.
> A quick look at the code makes me wonder why it couldn't work via the
> perform[with] code. That would make it pass on the same message,
> which might be good or bad depending on your needs.
Two reasons for not using #perform:[withArguments:]
a) It doesn't pass along the receiver of the message. For some of the
things I wanted to do this was critical and using "thisContext sender
receiver" was too ugly a hack for my taste.
b) It would imply that there's a 1-on-1 match between the message sent
and the (then implicit) #run: message. I thought about this but didn't
like it very much as I could think about cases where I wanted to use
#run: in one context and #perform: within another.