[squeak-dev] [Cuis-dev] Message>>#= & Message>>#hash
Juan Vuletich
juan at jvuletich.org
Tue Nov 20 15:56:01 UTC 2018
Hi Eliot,
(below)
On 19/11/2018 02:32 p.m., Eliot Miranda via Cuis-dev wrote:
> Hi All,
>
> In VisualWorks Message implements #= & #hash naturally; two
> messages whose selectors and arguments are #= are also equal. But in
> Cuis, Squeak and Pharo Message inherits #= and #hash from Object, i.e.
> uses identity comparison. This is, to say the least, annoying. Any
> objections to implementing comparing in Message to match VisualWorks?
>
> _,,,^..^,,,_
> best, Eliot
>
Just added these implementations to Cuis:
= aMessage
"Any object is equal to itself"
self == aMessage ifTrue: [ ^ true ].
self class == aMessage class ifFalse: [ ^false ].
selector = aMessage selector ifFalse: [ ^false ].
lookupClass = aMessage lookupClass ifFalse: [ ^false ].
^args = aMessage arguments
hash
"Hash is reimplemented because = is implemented."
^selector hash bitXor: args hash
Do they look ok? (I considered lookupClass for #=, but not for hash, as
collisions because of that seem unlikely, and in any case, grouping them
that way could be useful).
Cheers,
--
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20181120/0de9472d/attachment.html>
More information about the Squeak-dev
mailing list
|