Re: (sxhash (make-instance 'ext:standard-stablehash)) => 3614431684
Pascal Bourguignon <[email protected]> Sat, 13 Jan 2018 04:49:17 +0100
| Newsgroups | gmane.lisp.clisp.devel |
|---|---|
| Message-ID | <[email protected]> |
> On 12 Jan 2018, at 21:29, Bruno Haible <[email protected]> wrote: > > Hi Sam, > >> I understand that SXHASH is not guaranteed to be different for different >> instances: >> >> --8<---------------cut here---------------start------------->8--- >>> (sxhash (make-instance 'ext:standard-stablehash)) >> 3614431684 >>> (sxhash (make-instance 'ext:standard-stablehash)) >> 3614431684 >>> (sxhash (make-instance 'ext:structure-stablehash)) >> 83368493 >>> (sxhash (make-instance 'ext:structure-stablehash)) >> 83368493 >> --8<---------------cut here---------------end--------------->8--- >> >> However, it seems like it _could_ do better. > > Yes, it is conceivable that SXHASH looks into instances of > STANDARD-OBJECT or STRUCTURE-OBJECT, with a limited depth. I don’t agree. The specification says that: (equal x y) implies (= (sxhash x) (sxhash y)) But equal for instances means eq. That is, there is an expectation that SXHASH works only on the identity of the object, not on its slots. Furthermore, it means that the SXHASH shouldn’t change when you mutate the slots of the object! IMO, SXHASH for object shall depend only on the identity of the object. (This would also be consistent with the hash function used in HASH-TABLEs.) -- __Pascal J. Bourguignon__ ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ clisp-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/clisp-devel