[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
hash-table puzzlement
- To: clisp-list@ma2s2.mathematik.uni-karlsruhe.de
- Subject: hash-table puzzlement
- From: marcus@ee.pdx.edu (Marcus Daniels)
- Date: Sat, 11 Dec 93 15:24:37 PST
Could someone be so kinda as to tell me why this program reports
different values after compilation?
(eval-when (load compile eval)
(defvar base)
(defvar copies)
(defstruct base
(table (make-hash-table :test #'equal) :type hash-table))
(defstruct copies
(table1 (make-hash-table :test #'equal) :type hash-table)
(table2 (make-hash-table :test #'equal) :type hash-table))
(defun make-and-store-values-in-table ()
(setq base (make-base))
(setf (gethash "STR1" (base-table base)) 1)
(setf (gethash "STR2" (base-table base)) 2)
(setf (gethash "STR3" (base-table base)) 3)
base
)
(defun make-and-store-values-in-two-tables ()
(setq copies (make-copies))
(maphash #'(lambda (key value)
(setf (gethash key (copies-table1 copies)) value)
(setf (gethash key (copies-table2 copies)) value))
(base-table base))
copies
)
)
(defconstant base-stored `#.(make-and-store-values-in-table))
(defconstant copies-stored `#.(make-and-store-values-in-two-tables))
(terpri)
(princ (gethash "STR1" (copies-table1 copies-stored))) (terpri)
(princ (gethash "STR1" (copies-table2 copies-stored))) (terpri)