diff options
| author | Paul Eggert | 2020-04-19 15:09:02 -0700 |
|---|---|---|
| committer | Paul Eggert | 2020-04-19 15:12:05 -0700 |
| commit | e1d42da0d686e93534ee2abebe79bff95f18cb4d (patch) | |
| tree | 70f7d9b1fed7bf523a428cfa47c48ff0d27f3e43 /doc | |
| parent | 5805df74f5b919a3f67f3f7d31d6e600e1564e4e (diff) | |
| download | emacs-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.texi | 8 | ||||
| -rw-r--r-- | doc/lispref/objects.texi | 10 |
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 |
| 162 | to modify the constant's contents via @code{setcar}, @code{aset} or | 162 | should not attempt to modify their contents via @code{setcar}, @code{aset} or |
| 163 | similar primitives. The Lisp interpreter might unify the constants | 163 | similar primitives. The Lisp interpreter might unify the constants |
| 164 | yielded by your program's self-evaluating forms, so that these | 164 | yielded by your program's self-evaluating forms, so that these |
| 165 | constants might share structure. @xref{Constants and Mutability}. | 165 | constants might share structure. @xref{Constants and Mutability}. |
| @@ -704,8 +704,8 @@ Here are some examples: | |||
| 704 | @end example | 704 | @end example |
| 705 | 705 | ||
| 706 | If a subexpression of a backquote construct has no substitutions or | 706 | If a subexpression of a backquote construct has no substitutions or |
| 707 | splices, it acts like @code{quote} in that it yields a constant that | 707 | splices, it acts like @code{quote} in that it yields constant conses, |
| 708 | should not be modified. | 708 | vectors 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 |
| 2397 | mutable, some types contain both constant and mutable members. These | 2397 | mutable, some types contain both constant and mutable members. These |
| 2398 | types include conses, vectors, and strings. For example, the string | 2398 | types include conses, vectors, strings, and symbols. For example, the string |
| 2399 | literal @code{"aaa"} yields a constant string, whereas the function | 2399 | literal @code{"aaa"} yields a constant string, whereas the function |
| 2400 | call @code{(make-string 3 ?a)} yields a mutable string that can be | 2400 | call @code{(make-string 3 ?a)} yields a mutable string that can be |
| 2401 | changed via later calls to @code{aset}. | 2401 | changed 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}). |
| 2404 | A program should not attempt to modify other types of constants because the | ||
| 2404 | resulting behavior is undefined: the Lisp interpreter might or might | 2405 | resulting behavior is undefined: the Lisp interpreter might or might |
| 2405 | not detect the error, and if it does not detect the error the | 2406 | not detect the error, and if it does not detect the error the |
| 2406 | interpreter can behave unpredictably thereafter. Another way to put | 2407 | interpreter can behave unpredictably thereafter. Another way to put |
| 2407 | this is that mutable objects are safe to change, whereas constants are | 2408 | this is that although mutable objects are safe to change and constant |
| 2408 | not safely mutable: if you try to change a constant your program might | 2409 | symbols reliably reject attempts to change them, other constants are |
| 2410 | not safely mutable: if you try to change one your program might | ||
| 2409 | behave as you expect but it might crash or worse. This problem occurs | 2411 | behave as you expect but it might crash or worse. This problem occurs |
| 2410 | with types that have both constant and mutable members, and that have | 2412 | with types that have both constant and mutable members, and that have |
| 2411 | mutators like @code{setcar} and @code{aset} that are valid on mutable | 2413 | mutators like @code{setcar} and @code{aset} that are valid on mutable |