mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-05 19:59:38 +00:00
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.
This commit is contained in:
parent
5805df74f5
commit
e1d42da0d6
2 changed files with 10 additions and 8 deletions
|
@ -158,8 +158,8 @@ contents unchanged.
|
||||||
@end group
|
@end group
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
A self-evaluating form yields a constant, and you should not attempt
|
A self-evaluating form yields constant conses, vectors and strings, and you
|
||||||
to modify the constant's contents via @code{setcar}, @code{aset} or
|
should not attempt to modify their contents via @code{setcar}, @code{aset} or
|
||||||
similar primitives. The Lisp interpreter might unify the constants
|
similar primitives. The Lisp interpreter might unify the constants
|
||||||
yielded by your program's self-evaluating forms, so that these
|
yielded by your program's self-evaluating forms, so that these
|
||||||
constants might share structure. @xref{Constants and Mutability}.
|
constants might share structure. @xref{Constants and Mutability}.
|
||||||
|
@ -704,8 +704,8 @@ Here are some examples:
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
If a subexpression of a backquote construct has no substitutions or
|
If a subexpression of a backquote construct has no substitutions or
|
||||||
splices, it acts like @code{quote} in that it yields a constant that
|
splices, it acts like @code{quote} in that it yields constant conses,
|
||||||
should not be modified.
|
vectors and strings that should not be modified.
|
||||||
|
|
||||||
@node Eval
|
@node Eval
|
||||||
@section Eval
|
@section Eval
|
||||||
|
|
|
@ -2395,17 +2395,19 @@ somewhere else.
|
||||||
|
|
||||||
Although numbers are always constants and markers are always
|
Although numbers are always constants and markers are always
|
||||||
mutable, some types contain both constant and mutable members. These
|
mutable, some types contain both constant and mutable members. These
|
||||||
types include conses, vectors, and strings. For example, the string
|
types include conses, vectors, strings, and symbols. For example, the string
|
||||||
literal @code{"aaa"} yields a constant string, whereas the function
|
literal @code{"aaa"} yields a constant string, whereas the function
|
||||||
call @code{(make-string 3 ?a)} yields a mutable string that can be
|
call @code{(make-string 3 ?a)} yields a mutable string that can be
|
||||||
changed via later calls to @code{aset}.
|
changed via later calls to @code{aset}.
|
||||||
|
|
||||||
A program should not attempt to modify a constant because the
|
Modifying a constant symbol signals an error (@pxref{Constant Variables}).
|
||||||
|
A program should not attempt to modify other types of constants because the
|
||||||
resulting behavior is undefined: the Lisp interpreter might or might
|
resulting behavior is undefined: the Lisp interpreter might or might
|
||||||
not detect the error, and if it does not detect the error the
|
not detect the error, and if it does not detect the error the
|
||||||
interpreter can behave unpredictably thereafter. Another way to put
|
interpreter can behave unpredictably thereafter. Another way to put
|
||||||
this is that mutable objects are safe to change, whereas constants are
|
this is that although mutable objects are safe to change and constant
|
||||||
not safely mutable: if you try to change a constant your program might
|
symbols reliably reject attempts to change them, other constants are
|
||||||
|
not safely mutable: if you try to change one your program might
|
||||||
behave as you expect but it might crash or worse. This problem occurs
|
behave as you expect but it might crash or worse. This problem occurs
|
||||||
with types that have both constant and mutable members, and that have
|
with types that have both constant and mutable members, and that have
|
||||||
mutators like @code{setcar} and @code{aset} that are valid on mutable
|
mutators like @code{setcar} and @code{aset} that are valid on mutable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue