[squeak-dev] [Cuis-dev] Message>>#= & Message>>#hash
eliot.miranda at gmail.com
Tue Nov 20 21:59:15 UTC 2018
On Tue, Nov 20, 2018 at 8:00 AM Juan Vuletich <juan at jvuletich.org> wrote:
> Hi Eliot,
> 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 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).
> Juan Vuletichwww.cuis-smalltalk.orghttps://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Devhttps://github.com/jvuletichhttps://www.linkedin.com/in/juan-vuletich-75611b3
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev