Fwd: [squeak-dev] A puzzle for the New Year

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Wed Jan 7 17:25:12 UTC 2015


---------- Forwarded message ----------
From: Nicolas Cellier <nicolas.cellier.aka.nice at gmail.com>
Date: 2015-01-04 11:30 GMT+01:00
Subject: Re: [squeak-dev] A puzzle for the New Year
To: The general-purpose Squeak developers list <
squeak-dev at lists.squeakfoundation.org>


Ah, you mean like
http://stackoverflow.com/questions/27386061/overriding-compile-method-in-squeak/27413079#27413079

A picture is worth a few dozen of words indeed.

I'm pretty sure I saw a browser showing the whole metaclass hierarchy in
the past which also might be helpfull to better understand these corners,
but I just don't remember where exactly (st-80 v2.3?).

2015-01-02 12:01 GMT+01:00 Trygve Reenskaug <trygver at ifi.uio.no>:

>  Hi,
> I had to dive into  the deeper regions of Smalltalk when I was preparing
> BabyIDE for Monticello. I needed to specialize a class  *fileOut *method:
>
> BB5aMoneyTransferContext>>fileOutOn: aFileStream moveSource: moveSource
> toFile: fileIndex initializing: aBool
>     super fileOutOn: aFileStream moveSource: moveSource toFile: fileIndex
> initializing: aBool.
>     <my own additions>
>
> This works, but the *fileOutOn:moveSource:toFile:initializing:*-method is
> defined in class *Class* which is not a superclass of
> *BB5aMoneyTransferContext*. So *super *does not refer to the superclass!
> What's going on?
> --------------------------------------------------
> There are two essential object structures in Smalltalk: The instantiation
> tree and the class inheritance tree. They are independent but intertwined
> as described in chapter 16 of the Blue Book. It's pretty complicated in the
> general but fairly obvious in this concrete example.
>
> Smalltalk is all about objects, not classes.  I used my *Smalltalk
> Reverse Engineering (SRE)* tool and produced the attached object diagram.
> The notation in the diagram is
>
>    - a rectangle represents an object
>    - the object's name is [<oop>] : <class name>
>    - a line represents a link. An 'instanceOf' relationship is marked */self
>    class*; an inheritance relationship is marked *superclass*.
>
> The diagram shows that the answer to the puzzle is one 'instaceOf'
> relationship followed by four  'superclass' relationships. The departure
> from the usual is that while most class objects are instances of their own
> Metaclass. ProtoObject is an exception. It has no superclass, but its
> metaclass has. It is class Class. Add to this that when an object receives
> a message, it goes to its class to find the corresponding method.
> [1224]:MoneyTransferContext  receives the super fileout message. The VM
> goes to  the superclass of its class, [3253]:Metaclass and looks for the
> required method in its methodDict. It doesn't find it and continues up the
> superclass chain until it finds it in [1254]:Class class . Straight
> forward, isn't it.
>
> I hope you enjoy this dive into the innards of Smalltalk and wish you all
> A Happy New Year!
> --Trygve
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20150107/9281518e/attachment.htm


More information about the Squeak-dev mailing list