[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Make-Hash-Table
(I sent a version of this message earlier today, which apparently never got
back to me or anyone else at CMU. Here's another try. I added a new paragraph
while resending.)
I propose the following clarification to the specification of how the
:rehash-threshold and :rehash-size options interact:
There are four cases:
1. :rehash-threshold is an integer and :rehash-size is an integer.
In this case, when a hash table is grown (by adding rehash-size to
the current hash table size), the rehash-threshold is scaled up by
multiplying it by the ceiling of the ratio of the new size to the
original size.
2. :rehash-threshold is an integer and :rehash-size is a float.
In this case, when a hash table is grown (by multiplying the current
hash table size by the rehash-size), the rehash-threshold is scaled
up by multiply it, too, by the rehash-size.
3. :rehash-threshold is a float and :rehash-size is an integer.
In this case, when a hash table is grown (by adding rehash-size to
the current hash table size), we just leave the rehash-threshold
alone.
4. :rehash-threshold is a float and :rehash-size is a float.
To grow, just multiply the current hash table size by the rehash-size
and again leave the rehash-threshold alone.
If :rehash-threshold is a fixnum, then the hash table is grown when the number
of entries in the table exceeds the :rehash-threshold. If :rehash-threshold is
a float, then the hash table is grown when the ratio of the number of entries
in the to the size of the table exceeds the :rehash-threshold.
This seems to be the "obvious" interpretation of the description on pages
283-284, and this is how I intended to implement hash tables for Spice Lisp. I
believe I broke the behavior sometime when I was trying to eliminate non-fixnum
arithmetic from the system while bootstrapping a new instruction set. So,
those with our code: beware. I'll fix it soon.
Oh, I noticed there's a funny typo in the index. On page 461, instead of
":rehash-threshold keyword," it says ":rehash-threshold keyboard." I wonder if
there are any others like that.
--Skef