Confusion over basic Array new:

David Stes stes at mundivia.es
Fri Sep 18 08:35:50 UTC 1998


On Thu, 17 Sep 1998, Michael S. Klein wrote: 

> Hmm...  I wonder what
> 
> 	Behavior new superclass
> 
> should be?  I vote for nil, with Object being a close second.

It's returning nil, but I find this is a bit strange, perhaps because of
how I'm used to have things working in Objective-C (where only Object has
nil as superclass). 

Objective-C uses some sort of simplified form of what Squeak offers :
there is no separate metaclass hierarchy. 

The root class, Object, is the root for both instances and classes. 

  Object instance <------------ Object class
         ^                             ^
  Collection instance           Collection class
         ^                             ^
  OrderedCollection instance    OrderedCollection class

Where the arrow denotes in the left column how instance method lookup
proceeds, and in the right column how class (factory) message lookup
proceeds (ending the search for factory methods with Object's instance
methods). 

There is an instance method class (which returns the class) and a factory
method class (which returns self!). 

Like this, the 'class' message never returns metaclasses (although they do
exist in the VM). 
 
It's possible that this simplified model was derived from some older
Smalltalk implementation (I don't know). 

Or maybe when O-C was designed, they were thinking that Smalltalk's
metaclass model was too complicated. 





More information about the Squeak-dev mailing list