Overriding #class

Martin Beck martin.beck at hpi.uni-potsdam.de
Tue Nov 13 10:28:26 UTC 2007


we have a little problem while implementing a CodA meta-object protocol. 
The facility we try to implement now (or first :) ) is that every 
instance should have the possibility to add behaviour (i.e. methods) to 
it, but not to the class. Our first approach, which was also advised in 
Jeff McAffer's papers, was to insert 'anonymous' classes, which 
implement these methods and change the objects class to that new foo-class.

However, to retain normal behaviour, we want to override the #class 
method to return the real class of the object, not the inserted one. The 
CodA metastructure will be accessed through a #meta message.

As you might have expected, our problem is now, that the compiler 
optimizes the #class send and therefore the code only works in the 
debugger. Our question is now, whether there is an easy and shareable 
(Monticello, etc.) way to disable these optimizations and whether this 
idea could work with the current VM implementation? If the VM doesn't 
use the #class method to bind messages to an object to the methods of 
its class, we think that it could be possible, but if this lookup is not 
built into the VM but rather into the ST system, we have to go another 

Any ideas? Maybe replacing the object which shall be extended by a 
method with a proxy, catch every message and do the lookup ourselves?


More information about the Squeak-dev mailing list