Shouldn't I see the same hash value for both sxhash calls?
(defpackage "foo")
(in-package "foo")
(sxhash 'bar)
(defpackage "foo2")
(in-package "foo2")
(sxhash 'bar)
pTymN wrote:What about [...] this note at the end of the clhs entry on sxhash "Although similarity is defined for symbols in terms of both the symbol's name and the packages in which the symbol is accessible, item 3 disallows using package information to compute the hash code, since changes to the package status of a symbol are not visible to equal."
;;; The hash of a symbol does not change when its package changes
(deftest sxhash.23
(progn
(safely-delete-package "A")
(defpackage "A" (:use))
(let* ((pkg (find-package "A"))
(sym (intern "FOO" pkg))
(hash (sxhash sym)))
(unintern sym pkg)
(let ((hash2 (sxhash sym)))
(if (eql hash hash2) nil (list hash hash2)))))
nil)
theclapp wrote:That means that if you change package FOO, then the sxhash of FOO::BAR must remain the same after the change. It doesn't apply to two different symbols that are already not EQL.
pTymN wrote:Turns out, Corman CL has a bug in sxhash where if you call (gc 2), you'll get different return values from sxhash. His hash table implementations had a hook that would trigger a rehash after a GC.
Users browsing this forum: No registered users and 4 guests