[squeak-dev] [Cuis-dev] Message>>#= & Message>>#hash
Eliot Miranda
eliot.miranda at gmail.com
Tue Nov 20 21:59:15 UTC 2018
Hi Juan,
On Tue, Nov 20, 2018 at 8:00 AM Juan Vuletich <juan at jvuletich.org> wrote:
> 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
>
this last line should be
^args literalEqual: aMessage arguments
and this is very important :-)
>
> 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 Vuletichwww.cuis-smalltalk.orghttps://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Devhttps://github.com/jvuletichhttps://www.linkedin.com/in/juan-vuletich-75611b3
> @JuanVuletich
>
>
--
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20181120/6dea455f/attachment.html>
More information about the Squeak-dev
mailing list
|