— Scheme Procedure: **make-hash-table** [`equal-proc hash-proc #:weak weakness start-size`]

Create and answer a new hash table with

equal-procas the equality function andhash-procas the hashing function.By default,

equal-procis`equal?`

. It can be any two-argument procedure, and should answer whether two keys are the same for this table's purposes.My default

hash-procassumes that`equal-proc`

is no coarser than`equal?`

unless it is literally`string-ci=?`

. If provided,hash-procshould be a two-argument procedure that takes a key and the current table size, and answers a reasonably good hash integer between 0 (inclusive) and the size (exclusive).

weaknessshould be`#f`

or a symbol indicating how “weak” the hash table is:

`#f`

- An ordinary non-weak hash table. This is the default.
`key`

- When the key has no more non-weak references at GC, remove that entry.
`value`

- When the value has no more non-weak references at GC, remove that entry.
`key-or-value`

- When either has no more non-weak references at GC, remove the association.
As a legacy of the time when Guile couldn't grow hash tables,

start-sizeis an optional integer argument that specifies the approximate starting size for the hash table, which will be rounded to an algorithmically-sounder number.

By coarser than `equal?`

, we mean that for all `x` and
`y` values where `(`

`equal-proc` `x` `y``)`

,
`(equal? `

`x` `y``)`

as well. If that does not hold for
your `equal-proc`, you must provide a `hash-proc`.

In the case of weak tables, remember that references above
always refers to `eq?`

-wise references. Just because you have a
reference to some string `"foo"`

doesn't mean that an association
with key `"foo"`

in a weak-key table *won't* be collected;
it only counts as a reference if the two `"foo"`

s are `eq?`

,
regardless of `equal-proc`. As such, it is usually only sensible
to use `eq?`

and `hashq`

as the equivalence and hash
functions for a weak table. See Weak References, for more
information on Guile's built-in weak table support.