Overriding #class

Bert Freudenberg bert at freudenbergs.de
Tue Nov 13 10:35:34 UTC 2007

On Nov 13, 2007, at 11:28 , Martin Beck wrote:

> Hello,
> 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 way...

Wouldn't overriding #class break more things than it solves? After  
all, your object's class is not what it would claim to be.

Which "normal behavior" would you like to "retain"?

- Bert -

More information about the Squeak-dev mailing list