Hello
On 1/19/17, Jecel Assumpcao Jr. jecel@merlintec.com wrote: ...
One of my roles in the Squeak community has been to remember the past.
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?
-- Hannes
Morphs have basic attributes
Setters:
- #position: - #extent: - #color: - #name:
For the first three attributes getters are labeled the same [1]
For the 'name' attribut it is different. To get the name I have set I need to use #externalName.
m := (RectangleMorph new name: 'myRect') openInWorld.
m name
'a RectangleMorph<myRect>(115748)'
m externalName 'myRect'
--------------------------------------------------------------------- [1] Slides in markdown format
Morphs have a position ------------------------------------
Morph new position: 100@100; openInWorld; inspect.
In the Inspector
self position
gives
100@100
Morphs have an extent -------------------------------------
m := Morph new. m extent: 320@240. m openInHand. m inspect
In the Inspector
self extent
gives
320@240.
Morphs have a color ----------------------------------
m := Morph new. m color: Color red. m openInHand. m inspect
In the Inspector
self color
gives
Color red
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
squeak-dev@lists.squeakfoundation.org