Hi Guys,
For some experimentation I wanted to have the ability to have *any* object act as a compiled method, so that it can be 'invoked' as if it were a function. I've just published a package for this at SqueakMap.
http://map2.squeakfoundation.org/sm/package/b6a0d3eb-1241-4e3c-b790-e1995b59 9784
From the description:
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.
Cheers, - Andreas