[plt-dev] `hash', `hasheq', and `hasheqv'

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Fri Apr 23 11:00:43 EDT 2010

On Fri, Apr 23, 2010 at 10:37 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> For the `racket' language, I'd like to introduce `hash', `hasheq', and
> `hasheqv' constructors. They'd be just like `make-immutable-hash', etc,
> but they'd take the content of the hash as arguments that are
> alternately keys and values (so always an even number of arguments).

That looks nice.

On the topic of hashes, one thing that always bugs me about the
current hash API is the confusion between 'hash means hashequal' and
'hash means any kind of hash table'.  For example,

(hash? (hash ...)) => #t
(hash-eq? (hasheq ...)) => #t
(hash-eq? (hash ...)) => #f

all as you expect.

but

(hash? (hasheq ...)) => #t

I'm not sure what the best way to resolve this tension is.  One thing
that would help would be to add `hash-equal?', but I'm not sure about
the name.
-- 
sam th
samth at ccs.neu.edu


Posted on the dev mailing list.