Opened 7 years ago

Last modified 7 years ago

#1016 new enhancement

Custom hash table functions require symbols, not function designators

Reported by: dh Owned by:
Priority: normal Milestone:
Component: other Version: trunk
Keywords: Cc:


Inside make-hash-table, both the :test and :hash-function keyword values are checked for being symbolp or functionp, but whenever either of these values are actually used for custom hashing, the only acceptable type is symbol.

Since the default hash function values are function objects (#'%%equalhash et al), it does not seem incapable of accepting function objects. Storing function objects for custom hashing functions would also potentially run faster, skipping the lookup required for the symbol-function in use.

I don't think this is technically a defect as it doesn't conflict with CLHS, and I could not find any CCL documentation for the extended make-hash-table options to define the expected behavior either. But since the standard tests can work with function objects directly it does seem incongruous and a little misleading.

Change History (1)

comment:1 Changed 7 years ago by dh

Some examples of the incongruence:

(defun my-equal (a b) (equal a b))

(make-hash-table :test #'equal)                           ; ok
(make-hash-table :test #'equal :hash-function #'sxhash)   ; FAILS
(make-hash-table :test #'equal :hash-function 'sxhash)    ; ok
(make-hash-table :test #'my-equal :hash-function 'sxhash) ; FAILS
(make-hash-table :test 'equal :hash-function 'sxhash)     ; ok
Note: See TracTickets for help on using tickets.