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

Why is #'equalp not allowed in make-hash-table ?



    Date: 06 Nov 86 11:43:08 PST (Thu)
    From: sridhar%tekchips.tek.csnet@RELAY.CS.NET

     I want to create a hash table in which the keys are lisp objects
    that satisfy #'equalp. CLtL does not allow #'equalp  in :test
    argument to make-hash-table. Why?

The :test argument to make-hash-table is not user-extensible because of
the nature of hashing.  Each :test function has to have a corresponding
hashing function, which maps from an object to an integer that can be
used as an index into the hash table.  These two functions have to be
consistent in the sense that for any two objects A and B, if the test
function returns true when applied to A and B, then the hash function
must return the same integer for both A and B.

Because Common Lisp didn't want to provide portable ways for users to
write hashing functions (in general this requires implementation
dependent knowledge to do a good job), Common Lisp doesn't allow
arbitrary predicates to be provided for the :test argument.

I think your suggestion that equalp be added to the set of allowed
predicates is a good one.