Skip to content

Instantly share code, notes, and snippets.

@guicho271828
Created October 23, 2016 19:39
Show Gist options
  • Save guicho271828/5d025e2aff770a0042356b54fe75e0f5 to your computer and use it in GitHub Desktop.
Save guicho271828/5d025e2aff770a0042356b54fe75e0f5 to your computer and use it in GitHub Desktop.
Maybe undefined behavior?
(lisp-implementation-type)
"SBCL"
(lisp-implementation-version)
"1.3.9"
(defparameter a (make-hash-table :test 'equalp))
(defstruct b c d)
(defparameter b1 (make-b :c 0 :d 1))
(defparameter b2 (make-b :c 2 :d 1))
(defparameter b3 (make-b :c 0 :d 1))
(setf (gethash b1 a) 1)
(assert (eq (gethash b1 a) 1))
(assert (eq (gethash b2 a) nil))
(assert (eq (gethash b3 a) 1))
(print (list b1 b2 b3))
(setf (slot-value b1 'c) 2)
(print (multiple-value-list (gethash b1 a)))
(print (multiple-value-list (gethash b2 a)))
(print (multiple-value-list (gethash b3 a)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment