aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2019-06-15 11:16:49 +0300
committerEli Zaretskii2019-06-15 11:16:49 +0300
commit333170348ba83069c1f460af70e9add28d57da2a (patch)
tree9ff580652264df358e0b23863d41f8cde982a49e
parentf6a1647a8be9148b8db76aca601773968af7c343 (diff)
downloademacs-333170348ba83069c1f460af70e9add28d57da2a.tar.gz
emacs-333170348ba83069c1f460af70e9add28d57da2a.zip
Improve documentation of hash-code functions
* src/fns.c (Fsxhash_eq, Fsxhash_eql, Fsxhash_equal): * doc/lispref/hash.texi (Defining Hash): Warn against assuming that sxhash returns consistent results.
-rw-r--r--doc/lispref/hash.texi5
-rw-r--r--src/fns.c12
2 files changed, 14 insertions, 3 deletions
diff --git a/doc/lispref/hash.texi b/doc/lispref/hash.texi
index 5aaf31247b4..9b900e63099 100644
--- a/doc/lispref/hash.texi
+++ b/doc/lispref/hash.texi
@@ -333,6 +333,11 @@ and equal-looking objects are considered the same key.
333(make-hash-table :test 'contents-hash) 333(make-hash-table :test 'contents-hash)
334@end example 334@end example
335 335
336Lisp programs should @emph{not} rely on hash codes being preserved
337between Emacs sessions, as the implementation of the hash functions
338uses some details of the object storage that can change between
339sessions and between different architectures.
340
336@node Other Hash 341@node Other Hash
337@section Other Hash Table Functions 342@section Other Hash Table Functions
338 343
diff --git a/src/fns.c b/src/fns.c
index eaa2c07fbe4..fd0c7fc71a0 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4695,7 +4695,9 @@ sxhash (Lisp_Object obj, int depth)
4695 4695
4696DEFUN ("sxhash-eq", Fsxhash_eq, Ssxhash_eq, 1, 1, 0, 4696DEFUN ("sxhash-eq", Fsxhash_eq, Ssxhash_eq, 1, 1, 0,
4697 doc: /* Return an integer hash code for OBJ suitable for `eq'. 4697 doc: /* Return an integer hash code for OBJ suitable for `eq'.
4698If (eq A B), then (= (sxhash-eq A) (sxhash-eq B)). */) 4698If (eq A B), then (= (sxhash-eq A) (sxhash-eq B)).
4699
4700Hash codes are not guaranteed to be preserved across Emacs sessions. */)
4699 (Lisp_Object obj) 4701 (Lisp_Object obj)
4700{ 4702{
4701 return make_fixnum (hashfn_eq (NULL, obj)); 4703 return make_fixnum (hashfn_eq (NULL, obj));
@@ -4703,7 +4705,9 @@ If (eq A B), then (= (sxhash-eq A) (sxhash-eq B)). */)
4703 4705
4704DEFUN ("sxhash-eql", Fsxhash_eql, Ssxhash_eql, 1, 1, 0, 4706DEFUN ("sxhash-eql", Fsxhash_eql, Ssxhash_eql, 1, 1, 0,
4705 doc: /* Return an integer hash code for OBJ suitable for `eql'. 4707 doc: /* Return an integer hash code for OBJ suitable for `eql'.
4706If (eql A B), then (= (sxhash-eql A) (sxhash-eql B)). */) 4708If (eql A B), then (= (sxhash-eql A) (sxhash-eql B)).
4709
4710Hash codes are not guaranteed to be preserved across Emacs sessions. */)
4707 (Lisp_Object obj) 4711 (Lisp_Object obj)
4708{ 4712{
4709 return make_fixnum (hashfn_eql (NULL, obj)); 4713 return make_fixnum (hashfn_eql (NULL, obj));
@@ -4711,7 +4715,9 @@ If (eql A B), then (= (sxhash-eql A) (sxhash-eql B)). */)
4711 4715
4712DEFUN ("sxhash-equal", Fsxhash_equal, Ssxhash_equal, 1, 1, 0, 4716DEFUN ("sxhash-equal", Fsxhash_equal, Ssxhash_equal, 1, 1, 0,
4713 doc: /* Return an integer hash code for OBJ suitable for `equal'. 4717 doc: /* Return an integer hash code for OBJ suitable for `equal'.
4714If (equal A B), then (= (sxhash-equal A) (sxhash-equal B)). */) 4718If (equal A B), then (= (sxhash-equal A) (sxhash-equal B)).
4719
4720Hash codes are not guaranteed to be preserved across Emacs sessions. */)
4715 (Lisp_Object obj) 4721 (Lisp_Object obj)
4716{ 4722{
4717 return make_fixnum (hashfn_equal (NULL, obj)); 4723 return make_fixnum (hashfn_equal (NULL, obj));