Ticket #1016 (new enhancement)

Opened 22 months ago

Last modified 22 months ago

Custom hash table functions require symbols, not function designators

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

Description

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

comment:1 Changed 22 months 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.