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

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Fri Apr 23 11:04:16 EDT 2010

On Fri, Apr 23, 2010 at 11:00 AM, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:
> 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.

My $0.02:

We should add hashequal and hash-equal? to complete the symmetry.  The
hash? predicate should recognize all hash tables, and hash should
simply be a convenient shorthand for hashequal.  If we ever write a
comparison for hash tables, it should be hash=?.


Posted on the dev mailing list.