diff options
| -rw-r--r-- | doc/lispref/objects.texi | 15 |
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 | ||
| 2151 | The Emacs Lisp byte compiler may collapse identical literal objects, | ||
| 2152 | such as literal strings, into references to the same object, with the | ||
| 2153 | effect that the byte-compiled code will compare such objects as | ||
| 2154 | @code{eq}, while the interpreted version of the same code will not. | ||
| 2155 | Therefore, your code should never rely on objects with the same | ||
| 2156 | literal contents being either @code{eq} or not @code{eq}, it should | ||
| 2157 | instead use functions that compare object contents such as | ||
| 2158 | @code{equal}, described below. Similarly, your code should not modify | ||
| 2159 | literal objects (e.g., put text properties on literal strings), since | ||
| 2160 | doing that might affect other literal objects of the same contents, if | ||
| 2161 | the byte compiler collapses them. | ||
| 2147 | @end defun | 2162 | @end defun |
| 2148 | 2163 | ||
| 2149 | @defun equal object1 object2 | 2164 | @defun equal object1 object2 |