close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Opened 18 years ago

Closed 18 years ago

#5 closed defect (fixed)

Hash table entry with key and value of :EMPTY is treated as an empty entry.

Reported by: Raymond Toy Owned by: somebody
Priority: minor Milestone:
Component: Core Version: 19c
Keywords: Cc:


(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.

Change History (1)

comment:1 Changed 18 years ago by Raymond Toy

Resolution: fixed
Status: newclosed

Fixed in CVS. Should be available for the September snapshot.

Note: See TracTickets for help on using tickets.