Formal comment #189 (enhancement) hash-table-hash-function should return a function Reported by: Daniel Villeneuve Version: 5.92 SUMMARY The specification of hash-table-hash-function should not force implementations to return #f when something more useful is available. DESCRIPTION Quoting from http://www.r6rs.org/r6rs-editors/2006-March/001047.html, one can see that there were some arguments about the behavior of hash-table-hash-function for hash tables built from make-eq-hash-table and make-eqv-hash-table: >>Procedure: hash-table-hash-function hash-table => procedure >> >> Returns the hash function used by hash-table. > > > Should these procedures be defined on hash tables that > were created by calling make-eq-hash-table or > make-eqv-hash-table? You're right that hash-table-hash-function shouldn't be, so I've added provisional language to that effect. The current wording on page 52 requires that hash-table-hash-function return #f for such tables. I find some problems with this: a) This situation prevents implementations that can return useful functions to do so. b) This inhibits having a complete "hash-table-clone" method, which I think is one of the most useful usages for such inspection methods: (define (hash-table-clone ht k) (make-hash-table (hash-table-hash-function ht) (hash-table-equivalence-function ht) k)) c) On systems that provide users with public hash-eq and hash-eqv functions, the current wording forces the implementation to remember if a hash table was built using (make-eq-hash-table) or (make-hash-table hash-eq eq?), just for the sake of complying with the hash-table-hash-function's spec. PROPOSAL Alternative 1: on hash tables built using make-eq-hash-table and make-eqv-hash-table, hash-table-hash-function can return the implementation's choice of hash-function if this is available, or #f otherwise. This addresses issues a) and c), but not b). Alternative 2: hash-table-hash-function should always return a function, suitable to be used as a hash function by make-hash-table. For tables built using make-eq-hash-table and make-eqv-hash-table, the returned function can throw an exception if invoked. This addresses issues a), b) and c). RESPONSE: Allowing some implementations to return a procedure in the cases in question could encourage dependence on those procedures, resulting in non-portable programs. The proposal will not be adopted.