help!! - now "Hash the set"

Mike Klein mike at twinsun.com
Fri Apr 17 19:30:50 UTC 1998


> Absolutely right. I've never seen a case where using a collection as key
> would *really* be necessary.

I'm not sure this statement means anything more than the Church-Turing thesis.
I.E. Sure, there is always a way of restructuring your code that does the equivalent
computation without relying on Set equality.

However, the mere fact that there are people out here who use collections as keys
indicates that this is done.

Example of collections as keys:

	<Bag of: Sets>

I often do this while doing statistics on production systems (read "real world, paying"
not just "ivory tower").
This is what lead me to implement #= and #hash on Sets in the first place.
Incidentally, I've never seen any code broken by this that relies on Sets being
identity objects.

Math is hard.  If you want to play with #=, be prepared to pay the price.
Or just use #=, and trust the system.  By the way, the hash invariants not working
often lies dormant for ages, untill somebody actually tries to place disparate objects
in hashed collections.  For example:

3 asFraction hash
	=> 2
3 hash
	=> 3
3 asFraction = 3
	=> true

-- Mike Klein





More information about the Squeak-dev mailing list