[cmucl-ticket] #5: Hash table entry with key and value of :EMPTY is treated as an empty entry.
cmucl
cmucl-devel at common-lisp.net
Fri Jul 21 02:04:22 UTC 2006
#5: Hash table entry with key and value of :EMPTY is treated as an empty entry.
--------------------+-------------------------------------------------------
Reporter: rtoy | Owner: somebody
Type: defect | Status: new
Priority: minor | Milestone:
Component: Core | Version: 19c
Keywords: |
--------------------+-------------------------------------------------------
{{{
(defvar *h* (make-hash-table))
(setf (gethash :empty *h*) :empty)
(maphash #'(lambda (k v) (format t "~A -> ~A~%" k v)) *h*)
}}}
produces no output, but printing *h* indicates the hash table has one
entry in it.
This is a bug in how the hash tables indicate an empty slot. The key-
value vector uses a key and value of :EMPTY to indicate an empty slot.
A possible solution: The second slot in the key-value vector is the
symbol :EMPTY, but is otherwise not used for anything. So, instead of
putting :EMPTY there, we can put a gensym'ed symbol there instead, and
initialize all the remaining slots of the kv vector to be this symbol. I
don't think there's any impact on GC, because if the GC code needs the
empty symbol, it uses kv_vector![1] to get it. The Lisp code needs to
change to initialize the kv-vector appropriately. maphash and with-hash-
table-iterator need to use kv_vector![1] instead of :EMPTY to determine if
a slot is empty or not.
I think this should work.
--
Ticket URL: <http://trac.common-lisp.net/cmucl/ticket/5>
cmucl <http://common-lisp.net/project/cmucl>
cmucl
More information about the cmucl-ticket
mailing list