aboutsummaryrefslogtreecommitdiffstats
path: root/doc/lispref/objects.texi
diff options
context:
space:
mode:
authorPaul Eggert2020-04-19 15:09:02 -0700
committerPaul Eggert2020-04-19 15:12:05 -0700
commite1d42da0d686e93534ee2abebe79bff95f18cb4d (patch)
tree70f7d9b1fed7bf523a428cfa47c48ff0d27f3e43 /doc/lispref/objects.texi
parent5805df74f5b919a3f67f3f7d31d6e600e1564e4e (diff)
downloademacs-e1d42da0d686e93534ee2abebe79bff95f18cb4d.tar.gz
emacs-e1d42da0d686e93534ee2abebe79bff95f18cb4d.zip
Fix mutability glitches reported by Drew Adams
See Bug#40693#32. * doc/lispref/eval.texi (Self-Evaluating Forms, Backquote): Say that these yield constant conses, vectors and strings, not constant symbols. * doc/lispref/objects.texi (Constants and Mutability): Say that an attempt to modify a constant variable signals an error, instead of saying that it has undefined behavior.
Diffstat (limited to 'doc/lispref/objects.texi')
-rw-r--r--doc/lispref/objects.texi10
1 files changed, 6 insertions, 4 deletions
diff --git a/doc/lispref/objects.texi b/doc/lispref/objects.texi
index 98b001afd2d..b45eb7ad8a4 100644
--- a/doc/lispref/objects.texi
+++ b/doc/lispref/objects.texi
@@ -2395,17 +2395,19 @@ somewhere else.
2395 2395
2396 Although numbers are always constants and markers are always 2396 Although numbers are always constants and markers are always
2397mutable, some types contain both constant and mutable members. These 2397mutable, some types contain both constant and mutable members. These
2398types include conses, vectors, and strings. For example, the string 2398types include conses, vectors, strings, and symbols. For example, the string
2399literal @code{"aaa"} yields a constant string, whereas the function 2399literal @code{"aaa"} yields a constant string, whereas the function
2400call @code{(make-string 3 ?a)} yields a mutable string that can be 2400call @code{(make-string 3 ?a)} yields a mutable string that can be
2401changed via later calls to @code{aset}. 2401changed via later calls to @code{aset}.
2402 2402
2403 A program should not attempt to modify a constant because the 2403 Modifying a constant symbol signals an error (@pxref{Constant Variables}).
2404A program should not attempt to modify other types of constants because the
2404resulting behavior is undefined: the Lisp interpreter might or might 2405resulting behavior is undefined: the Lisp interpreter might or might
2405not detect the error, and if it does not detect the error the 2406not detect the error, and if it does not detect the error the
2406interpreter can behave unpredictably thereafter. Another way to put 2407interpreter can behave unpredictably thereafter. Another way to put
2407this is that mutable objects are safe to change, whereas constants are 2408this is that although mutable objects are safe to change and constant
2408not safely mutable: if you try to change a constant your program might 2409symbols reliably reject attempts to change them, other constants are
2410not safely mutable: if you try to change one your program might
2409behave as you expect but it might crash or worse. This problem occurs 2411behave as you expect but it might crash or worse. This problem occurs
2410with types that have both constant and mutable members, and that have 2412with types that have both constant and mutable members, and that have
2411mutators like @code{setcar} and @code{aset} that are valid on mutable 2413mutators like @code{setcar} and @code{aset} that are valid on mutable