Search code examples
smalltalksqueak

Is subclass: an ordinary method in Squeak?


It seems that creating a new subclass in Squeak is done by sending a message to the super class:

Object subclass: #Boolean
    instanceVariableNames: ''
    classVariableNames: ''
    poolDictionaries: ''
    category: 'Kernel-Objects'

Where can I look at the implementation of this method? I can't find it in Object's nor ProtoObject's class methods list.


Solution

  • Yes it is an ordinary message. The implementation is in the class called Class. You can find its implementation by selecting the message name in any class definition (like the one you posted in the question) and invoke the "implementors of it" action (Cmd-m, or in the pop up menu if you hold shift while clicking).

    You will find that it delegates to ClassBuilder, where you can see how new classes come into existence.

    Note that you send the message to the class Object, not to an instance of Object. That's why you did not find a method in Object or ProtoObject. You would rather have to look up the method in Object class, which is the metaclass of Object, and it inherits from Class.