#= and #hash

Mike Roberts mike at mjr104.co.uk
Mon Aug 18 13:00:56 UTC 2003


I have found a few more Text* objects that don't appear to behave well in Sets due to the lack of an implementation of #hash when #= is defined.  I thought I would have a look to see what the situation in the image was like.

Using this code (any better/neater way of doing it let me know!)

| hash equals |
hash _ (SystemNavigation new allImplementorsOf:#hash) collect:[:i| i classSymbol].
equals _ (SystemNavigation new allImplementorsOf:#=) collect:[:i| i classSymbol].
(hash reject:[:i | equals includes:i]) inspect.
(equals reject:[:i | hash includes:i]) inspect.

Gives the following results:

Implementors of #hash but not #= directly
ByteArray          #= from SequencableCollection
Collection         #= from Object
TranslucentColor   #= from Color (method says it handles this)

Implementors of #= but not #hash directly
CRLookupItem       #hash from Object
CharacterBlock	   #hash from Rectangle
CompiledMethod     #hash from ByteArray
Dictionary         #hash from Collection
Environment        #hash from Collection
FlashLineStyle	   #hash from Object
Heap               #hash from SequenceableCollection
RunArray           #hash from SequenceableCollection
Set                #hash from Collection
SortedCollection   #hash from SequenceableCollection
Symbol             #hash from String
TextAlignment      #hash from Object
TextAnchor         #hash from Object
TextEmphasis       #hash from Object
TextFontReference  #hash from TextFontChange
TextKern           #hash from Object
TextLine           #hash from Object
TextLineInterval   #hash from Interval
TextStyle          #hash from Object

All those classes that implement #= but take #hash from Object are, I think, bugs.  I'll make a start on tests/fixes for the Text* objects.

I just wanted to post this list to see if anyone more familiar with these methods could see any potential problems.

Cheers,

Mike



More information about the Squeak-dev mailing list