#= and #hash

Stephane Ducasse ducasse at iam.unibe.ch
Mon Aug 18 19:31:36 UTC 2003


Thanks for this effort! This is really good to have this kind of 
analysis.
I hope other will more contribute than me :) Still I want to encourage 
you identify where the system
can break and fixing it.

Stef

On Monday, August 18, 2003, at 03:00 PM, Mike Roberts wrote:

> 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