Ticket #5 (closed defect: fixed)

Opened 8 years ago

Last modified 8 years ago

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

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

Description

(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

Changed 8 years ago by rtoy

  • status changed from new to closed
  • resolution set to fixed

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

Note: See TracTickets for help on using tickets.