Shouldn't 2 hash = 2.0 hash? [LONG]

Andrew C. Greenberg werdna at gate.net
Tue Nov 30 13:56:24 UTC 1999


>I still think encapsulating the hash function with the target Set via a
>block (analagous to SortedCollection's sortBlock) is the way to do this.
>It allows the hash function to be customized to the need of the sub
>system (performance/efficiency vs. generality).

That works fine for sets of homogenous objects, but what to do when 
you are creating collections of arbitrary objects?  This approach 
(plugging hashBlocks), while attractive for some designs, feels to me 
like the sort of thing that would ultimately get refactored back down 
to the class hierarchy as a separate hash method on the elements.

The question ultimately comes down to the definition of hash. 
Presently, the Numeric objects break on that definition.  But I don't 
think they have to do so?  Why not simply make higher generality 
objects, like Float, hash to the same value as an integer when the 
Float is a whole number?





More information about the Squeak-dev mailing list