[plt-scheme] How to make unit functors?
At Wed, 28 May 2003 19:21:42 +0200, Jens_Axel_Søgaard wrote:
> I have just checked that even though 'j and 'J are eq?
> then have different hash-codes.
That can't be right.
> (eq? 'j 'J)
#t
> (eq-hash-code 'j)
511627
> (eq-hash-code 'J)
511627
The number will be different on your machine, but both `eq-hash-code'
results have to be the same number.
With case sensitivity, then 'j and 'J are different, and they likely
have different hash codes:
> #cs(eq? 'j 'J)
#f
> #cs(eq-hash-code 'j)
511627
> #cs(eq-hash-code 'J)
511621
Again, the number will be different on your machine. It's possible that
you get the same number from each use of `eq-hash-code' (instead of two
different numbers), but it's exceedingly unlikely.
> My idea about fixnums came from this part
>
> The number is an exact integer
> that is itself guaranteed to be eq? with any value representing the
> same exact integer (i.e., it is a fixnum).
>
> and got the idea that hashing a fixnum f would give a value which
> were eq? with any fixnum representing f (and thus also f it self).
> Which implies that (eq? f (eq-hash-code f)).
I see that the docs are confusing, and I'll try to improve it. Robby's
interpretation matches the intent.
As it turns out, `eq-hash-code' is the identity function on "fixnums",
but that wasn't the intent of the documentation (and as you suspect, it
could change in the future).
Matthew