[squeak-dev] Setter: aMorph name: 'theName' Getter: aMorph externalName

Jecel Assumpcao Jr. jecel at merlintec.com
Mon Jan 30 22:44:05 UTC 2017


Hannes Hirzel asked on Sat, 28 Jan 2017 14:15:47 +0100
> Recently I was wondering about the names of Morphs.
> 
> Setting a name is done with
> 
>      aMorph name: 'theName'
> 
> To get it back I need to do
> 
>      aMorph externalName
> 
> Maybe you know the historical reason for it?

Morphic was created as a direct manipulation user interface for Self.
This meant that the user could drop a morph inside another and at the
programming level this would show up as a new object being magically
added to the parent morph's subMorphs list. All code had to be written
in a way to decouple things as much as possible in order to allow this
to happen, though in my opinion the goal was not achieved.

Since Self doesn't organize object into a simple class tree it is not
always possible to use the pattern where "Object>>isHappy  ^ false" and
"HappySquare>>isHappy  ^ true" does the job of separating objects. The
more meta solution of #isKindOf: is even less of an option in Self. So
the extremely awkward solution of automatically generating names for
morphs and then using string pattern matching resulted in code like:

self submorphsDo: [ :m | (m morphTypeName 'RectangleMorph') ifTrue: [ m
...]]

This code doesn't break even if morphs are being dropped into and
dragged out of self while this is repeatedly executed.

I did not participate in this design and so can only guess the actual
motivations, but this string pattern matching horror was used in other
time critical parts of Self like in error handling for primitive fail
blocks. It might be that having Self be much faster than other
Smalltalks at the time made such quick and dirty designs attractive.

In Squeak (starting with Squeak 1.19b in the versions I have in this
machine, which isn't all of them) the #isKindOf: and #isX pattern was
used instead. My impression, which could be wrong, is that the name was
introduced to make compatibility between Morphic and MVC easier since it
was closely tied to MorphicModel.

Note that #name: is not a simple setter and #externalName is not a
simple getter. Instead, they look at several options and actually save
the name in the morph's list of extended properties.

-- Jecel


More information about the Squeak-dev mailing list