[squeak-dev] Overriding #= in Graphics and Sounds

Thiede, Christoph Christoph.Thiede at student.hpi.uni-potsdam.de
Thu Oct 1 12:23:28 UTC 2020


Hi all,


for a current project, I need to compare form or sound objects with each other, but I found out that they do not override #=, so for example, we get:


(ColorForm extent: 1 @ 1) = (ColorForm extent: 1 @ 1) --> false


Wasn't this implemented

a) simply because it looked like YAGNI?

b) for design reasons? For example, should (Form extent: 1 @ 1) be equal to (ColorForm extent: 1 @ 1) or not?

c) for performance reasons? I don't know if there any guidelines for implement #= (except that you need to implement #hash as well), but is an equality comparison generally allowed to be an expensive operation if two objects are equal? If two large forms have a different resolution or a different bitmap hash, comparison will be fast, but if they are equal, we will need to compare every single bit. Would this be okay or a no-go?


If implementing #= as proposed is not possible, how would you think about implementing it as a keyword message on Form, e.g. #sameAs:?


The same questions apply to the AbstractSound hierarchy, too, where I'm not sure whether two sounds being played for different duration should equal or not.

For a similar discussion, see also this thread: [squeak-dev] FormInspector, or also: Text>>#= and its consequences<http://forum.world.st/FormInspector-or-also-Text-gt-gt-and-its-consequences-td5121599.html>.

Best,
Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201001/79624322/attachment.html>


More information about the Squeak-dev mailing list