[BUG] ProtoObject class

Marcus Denker marcus at ira.uka.de
Fri Jul 7 19:34:42 UTC 2000


On Thu, Jul 06, 2000 at 02:37:56PM +0200, Johan Fabry wrote:
> Hi,
> 
> I found a bug regarding the 'class' message:
> 
> 'class' is defined in Object (as a primitive). However, subclasses of
> ProtoObject (which are not subclasses of Object), e.g. ObjectOut, still
> understand it. Try this: 'ObjectOut new class' It should raise a
> MessageNotUnderstood, but it doesn't, it nicely reports that the class
> is ObjectOut.
> 
> Also, if you define a 'class' method in a PrimitiveObject subclass (e.g.
> 'self halt.'), this code will not be executed, you will still get the
> class of the receiver.
> 
Yes. the "class"-Method is never called. There is a special bytecode for
this message-send generated by the compiler:

eg. a method  "1 class" will be compiled to

5 <76> pushConstant: 1
6 <C7> send: class
7 <87> pop
8 <78> returnSelf

That's Bytecode C7 (199) 

Now look at Interpreter class>>initializeBytecodeTable, there you will
find

 (199 bytecodePrimClass)

so primitive 111 (primitiveClass) never gets called, and it's even
not implemented in the Interpreter.     


> I was wondering, since I have never messed around with primitives, can I
> safely copy-paste the contents of the definition of 'class' into
> ProtoObject and then remove the definition from Object? (Have not tried
> it yet, just wondering if this will generate random crashes or some
> other ugly/unpredictable behaviour)

You can even delete it ;-) 


-- 
Marcus Denker marcus at ira.uka.de phone at home:(0721)6649375 @work:(0721)6082749
The Difference between today and yesterday is not so much what has changed
between then and now as what I hope to change by tomorrow.





More information about the Squeak-dev mailing list