[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Seeking review of sets and hash tables proposals

Alexey Radul scripsit:

> > So far I haven't heard about any *actual* cases of people requiring
> > specialized equivalence predicates, though it's easy to make up
> > hypotheticals.
> Really?
> How about record types?  equal? is not specified to compare their
> contents recursively, so if I want those semantics I have to force
> them with a custom equivalence predicate, and therefore a custom hash
> function.  I have written a hash function because of this, so this
> meets your criterion of non-hypotheticalness.

You are the first person to say so.

> How about sets?  Suppose I want to use sets as keys in a hash table,
> with set=? as the equivalence predicate?

What's the practical application of sets as keys?

In any case, hash functions for containers are easy to write:

  (lambda (cont)
      (lambda (elem) (xor (hash elem) acc))

where `hash` is an equality hash function.  This is perhaps an argument
for exposing `hash` from SRFI 69.

Note that nobody these days would clamor for fundamental laws        John Cowan
of *the theory of kangaroos*, showing why pseudo-kangaroos are   cowan@x
physically, logically, metaphysically impossible.    http://www.ccil.org/~cowan
Kangaroos are wonderful, but not *that* wonderful.     --Dan Dennett on zombies

Scheme-reports mailing list