[Newbies] Object new
cdshaffer at acm.org
Fri Jun 28 13:15:13 UTC 2019
> On Jun 28, 2019, at 8:16 AM, John McCulloch <johnnymcc9 at gmail.com> wrote:
> So when looking at how Smalltalk finds the implementation of a method, one should consider sending a message to a class is really sending a message to an instance of it's metaclass?
Yes! Although it seldom matters unless you’re manipulating classes beyond creating instances (or using class-side methods as utilities). So interesting messages like #superclass and #subclasses are not visible in the class-side of the browser but if you’re using those you’re probably pretty comfortable with looking at ClassDescription etc.
> If you look at it this way and follow the path starting at "Object class" it leads you to Behavior. It seems like this works differently than for user created classes where a class's superclass is the same as it's metaclass' superclass' instance.
The hierarchy’s are parallel except in rare cases where a class has a superclass of nil (like ProtoObject):
ProtoObject superclass ====> nil
ProtoObject class superclass ====> Class
Of course if you now follow the superclass chain from Class you end up back at ProtoObject and then nil. So, in most cases the only important exception to “every class has a superclass (that is a Class)” is ProtoObject (or Object in some Smalltalk’s).
> Btw, I think the diagram applies almost exactly to GNU Smalltalk's model.
Good to know. Doesn’t reflect Pharo or Squeak which both have ProtoObject above Object but its close enough.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners