[Newbies] Object new

David T. Lewis lewis at mail.msen.com
Thu Jun 27 13:09:57 UTC 2019

Hi John,

On Thu, Jun 27, 2019 at 07:01:31AM -0500, John McCulloch wrote:
> I was trying to decide whether I wanted to use GNU Smalltalk or Squeak.  My
> version of Ubuntu doesn't have a version of of gst with GUI that works so
> I'm going with Squeak.  This issue applies to both anyway.  It's not a
> problem but more of an issue about understanding how stuff works.

Welcome :-)

> The issue is with creating new classes by including "Object new".   The
> Object class doesn't have a #new method.   ProtoObject doesn't either.  
> Class Behavior has one but that is a subClass of Object.  Is this the #new
> that gets called and if so, how does Squeak know to use it?  If it's
> somewhere else, where is it?

Yes, you have it right. It is calling Behavior>>new.

You can explore this interactively as follows:

- Open a new workspace, and type "Object new" in the workspace.

- Highlight "Object new" and do a right-click to bring up a menu of options.

- Select "Debug it" from the menu.

- This will begin evaluation of the "Object new" expression, running in a debugger.

- Click the "Into" button in the debugger to step into the "new" method, which
is an instance-side method in class Behavior.

You are actually exploring a tricky and interesting part of the system
at this point. To get an idea of how it works, try this:

- In your workspace, type "Class".

- Right-click, and "inspect it" from the menu.

- You will get an inspector on "Class class".

- Look at the instance variables for class Class in the inspector,
and have a look at "subclasses".

- You will see that ProtoObject class is a subclass of class Class.

If you look at ProtoObject in a browser, you see it as the root of the
entire hierarchy of classes. But that connection you saw in the inspector
on "Class class" provides hidden magic.


More information about the Beginners mailing list