[squeak-dev] Item equality in PluggableTreeMorph

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


> 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.

Best,
Marcel
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.

Best,
Marcel
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
--
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/07d09dc0/attachment.html>


More information about the Squeak-dev mailing list