2009/5/17 Christophe Rhodes <csr21@...>:
> More generally, I can implement your scheme (coupled equality/hash) on
> top of independent equality and hash functions transparently and with
> ease. The reverse, while possible is going to be terribly icky:
> defining a new synonym for an equality function to get hold of a new
> I wouldn't mind an uncoupled scheme with a default for a given
> equality, though. Would that be sufficiently easy to use for you
> while remaining sufficiently general for me?
Something like the attached, maybe? Relevant docstring bits below for
Determines how keys are compared. Must a designator for one of the
standard hash table tests, or a hash table test defined using
SB-EXT:DEFINE-HASH-TABLE-TEST. Additionally, when an explicit
HASH-FUNCTION is provided (see below), any two argument equivalence
predicate can be used as the TEST.
If NIL (the default), a hash function based on the TEST argument is used,
which then must be one of the standardized hash table test functions, or
one for which a default hash function has been defined using
SB-EXT:DEFINE-HASH-TABLE-TEST. If HASH-FUNCTION is specified, the TEST
argument can be any two argument predicate consistent with it. The
HASH-FUNCTION is expected to return a non-negative fixnum hash code.
Defines NAME as a new kind of hash table test for use with the :TEST
argument to MAKE-HASH-TABLE, and associates a default HASH-FUNCTION with it.
NAME must be a symbol naming a global two argument equivalence predicate.
Afterwards both 'NAME and #'NAME can be used with :TEST argument. In both
cases HASH-TABLE-TEST will return the symbol NAME.
HASH-FUNCTION must be a symbol naming a global hash function consistent with
the predicate, or be a LAMBDA form implementing one in the current lexical
environment. The hash function must compute the same hash code for any two
objects for which NAME returns true, and subsequent calls with already hashed
objects must always return the same hash code.
Note: The :HASH-FUNCTION keyword argument to MAKE-HASH-TABLE can be used to
override the specified default hash-function.
Attempting to define NAME in a locked package as hash-table test causes a
package lock violation.