introspection Shiro Kawai 26 Apr 2005 08:27 UTC

IMHO, it is also important to have a query mechanism to know
the comparison and hash criteria of a given hash table.
Something like hash-table-type which returns a clue so that
you can know at least the given hash table uses which one of
system-builtin criteria (e.g. eq?, eqv?, equal?, string, string-ci, ...)
or some user-defined custom functions.  A function to query
a hash table's comparison/hash functions may be acceptable
if the default hashtables (created by make-symbol-hash-table etc.)
are guaranteed to return functions which are eq? to the known
functions (e.g. make-string-hash-table to return string=? as comparison
and string-hash as hash).

It is necessary when you want to get some external representation
of a hash table, for example, a marshalizer to send a Scheme
structure over the network.  Such a function probably can't deal
with hashtables with arbitrary comparison/hash functions, but it
is still pretty useful if it deals with standard hashtables.
Without the query mechanism, such a function can do nothing but
abort when it sees a hash table.  hash-table->list won't help.

--shiro