[squeak-dev] Item equality in PluggableTreeMorph

Marcel Taeumel marcel.taeumel at hpi.de
Wed Oct 27 07:47:07 UTC 2021

One more thing: Note that in DirectoryChooserDialog, the domain of directories/paths is the special case here. It's textual representation (i.e. state) encodes its identity at the same time. We don't have this case with generic objects and their #printString or #= implementation in the image. That's why Views/Widgets must work with #== by default unless the model knows better.

Am 27.10.2021 09:40:01 schrieb Marcel Taeumel <marcel.taeumel at hpi.de>:
> We should promote the #== check to a domain-specific callback to the model.

The typical implementation according to our existing code base would be something like this:

(self model respondsTo: compareSelector)
  ifTrue: [self model perform: compareSelector with: a with: b]
  ifFalse: [a == b].

Well, you could hard-code compareSelector. Yet, I would keep that #respondsTo: check and avoid inflating any generic Model class any further.

Am 27.10.2021 09:24:08 schrieb Marcel Taeumel <marcel.taeumel at hpi.de>:
Hi Tim --

+1 Yes, that would work. We should promote the #== check to a domain-specific callback to the model.

Am 26.10.2021 21:29:42 schrieb tim Rowledge <tim at rowledge.org>:
A solution I like in these situations is to add a very explicitly domain linked method to do the comparison. Don't use #= or #== - use #compareForWibbleMorphFlipTestingWith: etc. Be willing to do multiple-dispatch tricks to help discriminate what any particular class needs.

You gain some explanatory value in the method name, you have a good place to document the expectations in the method, and you can delegate to other class if needed.

> On 2021-10-25, at 10:36 PM, wrote:
> Alright, already found a regression with ToolBuilder-Morphic-ct.279. In #((()) (())), you cannot select the last leaf any longer.
> Hm, nevertheless this is a sad restriction. In pluggable lists (by item), we also use value equality/#= (see PluggableListMorphByItem >> #getCurrentSelectionIndex); this is just not consistent.

tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Oxymorons: Same difference

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20211027/bd624f3b/attachment.html>

More information about the Squeak-dev mailing list