[squeak-dev] Overriding #= in Graphics and Sounds
Marcel Taeumel
marcel.taeumel at hpi.de
Thu Oct 1 12:43:38 UTC 2020
Hi Christoph.
Hmmm... maybe it is not straightforward to implement? Especially whether #class (or #species) should match or not. Reminds me of SequenceableCollection >> #= and #hasEqualElements:. I keep on using #hasEqualElements: in tests because I don't care about Array-vs-OrderedCollection in several places.
And Form has also a non-trivial hierarchy of variations:
For example, would you ignore the #depth if it is black and white anyway?
Or would you break uses of Dictionaries that are virtually IdentityDictionaries because of their current keys and the missing #=?
It can be hard. Maybe it needs to be maintined afterwards. So, YAGNI? :-)
Best,
Marcel
Am 01.10.2020 14:23:37 schrieb Thiede, Christoph <christoph.thiede at student.hpi.uni-potsdam.de>:
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/fa224d2b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 98235 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201001/fa224d2b/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 81778 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201001/fa224d2b/attachment-0003.png>
More information about the Squeak-dev
mailing list
|