eq and hashing (was Re: [plt-scheme] How to make unit functors?)

From: Jacob Matthews (jacobm at cs.uchicago.edu)
Date: Thu May 29 09:16:03 EDT 2003

On Wed, 28 May 2003, Robby Findler wrote:

> ...
>
> > I don't quite follow. If you keep only the hash code, how do you know
> > that it has something to do with 'l (as opposed to, say, 'foo)?
>
> You don't -- all you know is that next time you get a 'l passed into
> the data structure, you want the same answer to come out. Now you don't
> get that.

Here's a real-world situation that's affected by this property: a while
back, Mike Machenry and I implemented a functional-sets library a using a
binary search tree as the underlying set representation. Of course we had
to have keys that would all be comparable with each other for this
representation to work out, but it didn't particularly matter what the
keys were, so we just used each item's hash value as its binary-tree key.
Now it sounds as though symbols inserted into these sets will get lost in
programs that rely on the property that 'a = 'a, so our sets have a bug.

-jacob


Posted on the users mailing list.