[BUG?] ProtoObject class superclass = nil

Andrew P. Black black at cse.ogi.edu
Sat May 25 01:32:38 UTC 2002


At 7:32 -0700 05/23/2002, Dan Rozenfarb wrote:
>
>Hi all,
>I was preparing the class about metaclasses for our
>students, which tend to be scared about such issues,
>when I got scared myself.
>Much to my surprise, ProtoObject class superclass
>returns nil.  I was expecting it to return Class, but
>nope.  Am I wrong?

The nomenclature is a bit confusing, but I don't think that you have 
found a bug.

If you do a "printIt" on

	ProtoObject class superclass

you will indeed get

	Class

as you expect.

However, if you inspect ProtoObject, you get an inspector window 
headed "ProtoObject class", and if you look at the instance variable 
superclass, it is indeed nil.

The confusion arises because the heading on an inspector window is 
the *class* of the object that you are inspecting, which is not the 
same as the object that you are inspecting.  So, if you inspect 
'abc', the inspector window is headed "String", and if you inspect 
String the inspector window is headed "String class".

Hence, if you inspect

	ProtoObject class

you get an inspector with the heading Metaclass.  Its superclass 
instance variable is indeed Class.

We might reduce the confusion a bit if the heading on the Inspector 
window was the result of "printOn:" on the object, i.e., what is 
displayed in the self slot of the inspector.  You can change this if 
you wish, by redefining Object>>defaultLabelForInspector .  Of 
course, if you do this and your students don't, the confusion might 
actually increase ...

	Andrew




More information about the Squeak-dev mailing list