aboutsummaryrefslogtreecommitdiffstats
path: root/doc
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
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')
-rw-r--r--doc/lispref/eval.texi8
-rw-r--r--doc/lispref/objects.texi10
2 files changed, 10 insertions, 8 deletions
diff --git a/doc/lispref/eval.texi b/doc/lispref/eval.texi
index deb288943af..f33c2faac10 100644
--- a/doc/lispref/eval.texi
+++ b/doc/lispref/eval.texi
@@ -158,8 +158,8 @@ contents unchanged.
158@end group 158@end group
159@end example 159@end example
160 160
161 A self-evaluating form yields a constant, and you should not attempt 161 A self-evaluating form yields constant conses, vectors and strings, and you
162to modify the constant's contents via @code{setcar}, @code{aset} or 162should not attempt to modify their contents via @code{setcar}, @code{aset} or
163similar primitives. The Lisp interpreter might unify the constants 163similar primitives. The Lisp interpreter might unify the constants
164yielded by your program's self-evaluating forms, so that these 164yielded by your program's self-evaluating forms, so that these
165constants might share structure. @xref{Constants and Mutability}. 165constants might share structure. @xref{Constants and Mutability}.
@@ -704,8 +704,8 @@ Here are some examples:
704@end example 704@end example
705 705
706If a subexpression of a backquote construct has no substitutions or 706If a subexpression of a backquote construct has no substitutions or
707splices, it acts like @code{quote} in that it yields a constant that 707splices, it acts like @code{quote} in that it yields constant conses,
708should not be modified. 708vectors and strings that should not be modified.
709 709
710@node Eval 710@node Eval
711@section Eval 711@section Eval
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