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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu May 29 16:15:10 EDT 2003

At Thu, 29 May 2003 14:07:33 -0400, "Joe Marshall" wrote:
> Wouldn't it suffice to make symbol hashing insensitive to their physical
> address?

What does the hash code have to do with the physical address?

Yes, there's something about the lifetime of a symbol reference that
affects its eq hash code, but there's no need to resort to such
ficticious entities as "physical addresses". :)

Less abstractly, run mzscheme3m and your symbol may actually jump
around a lot in "physical address" space, but the symbol will keep its
hash code.

At Thu, 29 May 2003 14:29:37 -0500, Robby Findler wrote:
> So, the hash for an interned symbol could be computed from its printed
> representation. 

If you're willing to pay for that (and it's a fairly small cost for
typical symbol sizes), then use `equal-hash-code'.

The bottom line is that `eq-hash-code' isn't always the right thing,
just as `eq?' isn't always the right thing. But `eq?' is sometimes
sufficient, and so is `eq-hash-code'.

Specification/documentation is a concern. Hopefully last night's doc
build makes the specification clearer. Further comments on the
documentation are apreciated.

Matthew



Posted on the users mailing list.