srfi-69- Basic hash tables
This module is a thin adaptor on Gauche’s built-in hashtables
(see Hashtables). This is provided for the compatibility
to the portable libraries; the hashtable object created by
make-hash-table is the same as the one
created by Gauche’s built-in, and you can pass the table to
Here’s a summary of difference between srfi-69 and Gauche’s built-in hash table API:
make-hash-table, as well as
alist->hash-table, takes equality predicate and hash function, instead of a single comparator argument.
make-hash-tabletakes two arguments, an object to calculate a hash value, and a positive integer that limits the range of the hash value.
Srfi-69’s primary hash table accessor is
hash-table-ref, which takes a thunk to be called when the table doesn’t have an entry for the given key, while Gauche’s
hash-table-gettakes a fallback value for that.
hash-table-ref/default, which takes a fallback value like Gauche’s
hash-table-get, but the default value can’t be omitted.
hash-table-walk, which is Gauche’s
hash-table-for-each. The srfi name is chosen to avoid conflict with existing Scheme implementations.
The following procedures are the same as Gauche’s built-in ones. See Hashtables, for the details.
hash-table? hash-table-delete! hash-table-exists? hash-table-keys hash-table-values hash-table-fold hash-table->alist hash-table-copy
[SRFI-69] Creates a new hashtable and returns it. This is the same name as Gauche’s built-in procedure, but the arguments are different.
The eq-pred argument is an equality predicate; it takes
two arguments and returns
#t if two are the same,
#f if not. When omitted,
equal? is used.
The hash-proc argument is a hash function.
It takes two arguments: an object to hash, and a positive
integer to limit the range of the hash value. (Note that
Gauche’s native hash functions takes only one argument.)
When omitted, Gauche tries to choose appropriate hash function
eq-pred is known one (
Otherwise we use Gauche’s
hash procedure, but there’s
no guarantee that it works appropriately; you should give
suitable hash-proc if you pass custom eq-pred.
The returned hash table is an instance of Gauche’s native hash table. You can pass it to Gauche’s builtin procedures.
Srfi-69 allows implementation-specific arguments args to be
make-hash-table. At this moment, Gauche
Like Gauche’s builtin
alist->hash-table, but takes
eq-pred and hash-fn separately,
instead of a single comparator.
The alist argument is a list of pairs. The car of each pair is used for a key, and the cdr for its value.
make-hash-table above for the description of
eq-pred, hash-fn and args.
[SRFI-69] Returns equivalence function and hash function of the hashtable ht.
The hash function returned from
takes two arguments, an object to hash and bound, a positive exact integer.
Note that the function returned by
hash-table-hash-function may not
eq? to the one you gave to
[SRFI-69] Looks up the value corresponding to key in a hash table ht. If there’s no entry for key, thunk is called without arguments. The default of thunk is to signal an error.
Looks up the value corresponding to key in a hash table ht.
This is like Gauche’s
hash-table-get, but default can’t be
This is the same as Gauche’s
Returns the number of entries in a hash table ht. The same as Gauche’s
For each entry in a hash table ht,
calls proc with two arguments, a key and its value.
It’s the same as Gauche’s
[SRFI-69] Add all entries in a hash table ht2 into a hash table ht1, and returns ht1.
hash, except this one can take bound argument;
if provided, it must be a positive integer, and the return value
is limited between 0 and
(- bound 1), inclusive.
These are like
srfi-13’s (see String library), except
these don’t take start and end argument.
This is Gauche’s
eq-hash, except this one can take bound argument.