Overriding #class

bryce at kampjes.demon.co.uk bryce at kampjes.demon.co.uk
Tue Nov 13 23:06:53 UTC 2007

Martin Beck writes:
 > Bert Freudenberg schrieb:
 > > 
 > > 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"?
 > Infact, we don't want to override Object>>#class but the #class in our 
 > generated anonymous class. It would look like this:
 > AnonymousClass>>#class
 > 	^self baseClass
 > So normal system behaviour is not changed, only if you alter an instance 
 > by for example adding a method, an anonymous class in the class chain is 
 > inserted which overrides the #class method. One reason to do this, is 
 > that the CodA paper specifies this behaviour, too. Another one would be, 
 > if somewhere in the system instances are tested for their classes (which 
 > shouldn't be the case...).

I'd suggest disabling the bytecode that implements the class message.
It doesn't do a message look-up. You could do this either by
converting the bytecode to a normal send (there's several bytecodes
that just do sends so this should be easy) or by modifying the
compiler to generate a normal send bytecode with a selector in the
literal frame.

I doubt that disabling this optimisation will cause problems but
could be wrong.


More information about the Squeak-dev mailing list