aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorEli Zaretskii2018-06-08 18:06:34 +0300
committerEli Zaretskii2018-06-08 18:06:34 +0300
commitef35d405b1208a01f3e31b44247fedd058fa9b2f (patch)
tree74c4ae2c740ac29680442e564a49211483836ba2 /doc
parentc6ef3c8321e4907a250eb0906274f6f59d5bfe0d (diff)
downloademacs-ef35d405b1208a01f3e31b44247fedd058fa9b2f.tar.gz
emacs-ef35d405b1208a01f3e31b44247fedd058fa9b2f.zip
Clarify subtle issues with 'eq' in byte-compiled code
* doc/lispref/objects.texi (Equality Predicates): Explain why byte-compiled code might compare literal objects with identical contents as 'eq'. (Bug#31688)
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/objects.texi15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
index af740625adb..c7e751cbd8c 100644
--- a/doc/lispref/objects.texi
+++ b/doc/lispref/objects.texi
@@ -2144,6 +2144,21 @@ Symbols}.
2144 @result{} nil 2144 @result{} nil
2145@end group 2145@end group
2146@end example 2146@end example
2147
2148@noindent
2149@cindex identical-contents objects, and byte-compiler
2150@cindex objects with identical contents, and byte-compiler
2151The Emacs Lisp byte compiler may collapse identical literal objects,
2152such as literal strings, into references to the same object, with the
2153effect that the byte-compiled code will compare such objects as
2154@code{eq}, while the interpreted version of the same code will not.
2155Therefore, your code should never rely on objects with the same
2156literal contents being either @code{eq} or not @code{eq}, it should
2157instead use functions that compare object contents such as
2158@code{equal}, described below. Similarly, your code should not modify
2159literal objects (e.g., put text properties on literal strings), since
2160doing that might affect other literal objects of the same contents, if
2161the byte compiler collapses them.
2147@end defun 2162@end defun
2148 2163
2149@defun equal object1 object2 2164@defun equal object1 object2