[Cuis-dev] How to represent Morphs with multiple parents in Morphic?

ken.dickey at whidbey.com ken.dickey at whidbey.com
Tue Mar 26 13:03:12 PDT 2024


On 2024-03-26 12:31, Ian Jeffries via Cuis-dev wrote:

> For instance this might be an edge in a graph which connects two nodes. 
> Or to use a more specific example this might be a segment of Highway or 
> River between two Cities.

Morphs, along with their code, are the visible representation and have 
strict _visual_ containment.

This is unrelated ("orthogonal") to other relations like connections 
between nodes.

> I'd like to say that the Highway has two parents, so if either City is 
> removed then the Highway is removed as well. However the Morph/submorph 
> relationship is strictly hierarchical so this isn't possible.

You can have a glass in a bottle in a bucket, but you can't have the 
glass in two separate buckets.  ?Remove either bucket and the glass is 
removed as well?

The metaphor does not work in this case.

> This makes me think the right thing to do is to place the edges at the 
> same level in the Morph hierarchy as the nodes. Thus a Highway and both 
> the Cities it connects would all be same-level submorphs of their 
> parent. I can override the `delete` message of City to remove any 
> adjacent Highways that start or end there.

Both cities may be in a country.  If you delete (nuke?) one city you 
might update the node/highway relationships.  A city may span a border.  
Does either country strictly "contain" the city?

> However, that would mean City needs to know about each object that 
> might be an implicit submorph of it in this way. Another strategy would 
> give morphs some kind of `implicitParents` field (not a real name 
> suggestion), and when a morph is deleted it checks for any adjacent 
> morphs that list it as an `implicitParent` and deletes those as well.
> 
> Does it seem like I'm on the right track, and does anyone have 
> suggestions for the best way to handle this?

One way to think of this is like "creation relations".  You want to 
maintain relationships, which may themselves be represented as objects.

E.g. one creates an automobile, but each gets its own tires, engine, 
windshield.  Deleting a GM factory does not delete the cars or their 
engines.  Deleting a road does not delete the cars.

So my suggestion would be to use consistent object metaphors.

I would hope you might have time to look at tutorials and examples in 
https://github.com/Cuis-Smalltalk/Learning-Cuis

HTH,
-KenD


More information about the Cuis-dev mailing list