[Cuis-dev] Inconsistent #= and #hash

Luciano Notarfrancesco luchiano at gmail.com
Tue Jun 11 04:49:04 PDT 2019

I did this to fish for inconsistencies:

instances _ OrderedCollection new.
Object withAllSubclassesDo: [:each| instances addAll: each allInstances].
instances _ instances asArray.

1 to: instances size do: [:i|
    a _ instances at: i.
    aHash _ a hash.
    i+1 to: instances size do: [:j|
        b _ instances at: j.
        (a = b and: [(aHash = b hash and: [b = a]) not]) ifTrue: [self

(I typed it manually here, I hope I copied it right, but you get the idea.)

Found out this:
- FeatureRequest forgets to implement hash;
- #() = Semaphore new, but not the other way around, and hashes also differ;
- similarly, LinkedList new = Semaphore new;
- RunArray new = Object new fails because it assumes the argument is a
Collection and sends isSequenceable;
- RunArray new = Text new, but hashes differ;
- Set new = Dictionary new but hashes differ;

And there are more, I stopped before finishing.

I don't know how to fix some of those, and the implications of changing the
behavior of #= or #hash are not obvious in some cases. But I think we
should change Collection>>hash to set the initial value to 0 instead of
'self species hash', and that would fix two of the issues above. What do
you think? Other ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20190611/4e7d26db/attachment-0001.htm>

More information about the Cuis-dev mailing list