aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2020-04-19 13:22:10 -0700
committerPaul Eggert2020-04-19 13:29:57 -0700
commit5805df74f5b919a3f67f3f7d31d6e600e1564e4e (patch)
tree02fdc2730ab35f3376c91fef2486afb0d31abd87
parentdca35b31d0a58efdcc698faf90493b96fa8e1406 (diff)
downloademacs-5805df74f5b919a3f67f3f7d31d6e600e1564e4e.tar.gz
emacs-5805df74f5b919a3f67f3f7d31d6e600e1564e4e.zip
Improve mutability doc
See Eli Zaretskii’s suggestions (Bug#40671#33). * doc/lispref/lists.texi (Setcar, Setcdr, Rearrangement): * doc/lispref/sequences.texi (Sequence Functions) (Array Functions): Add commentary to examples. * doc/lispref/lists.texi (Sets And Lists): Revert change to delq example.
-rw-r--r--doc/lispref/lists.texi16
-rw-r--r--doc/lispref/sequences.texi14
2 files changed, 15 insertions, 15 deletions
diff --git a/doc/lispref/lists.texi b/doc/lispref/lists.texi
index f1acc85616f..1125af7bec3 100644
--- a/doc/lispref/lists.texi
+++ b/doc/lispref/lists.texi
@@ -911,7 +911,7 @@ value @var{object}. For example:
911 911
912@example 912@example
913@group 913@group
914(setq x (list 1 2)) 914(setq x (list 1 2)) ; @r{Create a mutable list.}
915 @result{} (1 2) 915 @result{} (1 2)
916@end group 916@end group
917@group 917@group
@@ -931,7 +931,7 @@ these lists. Here is an example:
931 931
932@example 932@example
933@group 933@group
934;; @r{Create two lists that are partly shared.} 934;; @r{Create two mutable lists that are partly shared.}
935(setq x1 (list 'a 'b 'c)) 935(setq x1 (list 'a 'b 'c))
936 @result{} (a b c) 936 @result{} (a b c)
937(setq x2 (cons 'z (cdr x1))) 937(setq x2 (cons 'z (cdr x1)))
@@ -1022,11 +1022,11 @@ reached via the @sc{cdr}.
1022 1022
1023@example 1023@example
1024@group 1024@group
1025(setq x (list 1 2 3)) 1025(setq x (list 1 2 3)) ; @r{Create a mutable list.}
1026 @result{} (1 2 3) 1026 @result{} (1 2 3)
1027@end group 1027@end group
1028@group 1028@group
1029(setcdr x '(4)) 1029(setcdr x '(4)) ; @r{Modify the list's tail to be a constant list.}
1030 @result{} (4) 1030 @result{} (4)
1031@end group 1031@end group
1032@group 1032@group
@@ -1135,11 +1135,11 @@ Unlike @code{append} (@pxref{Building Lists}), the @var{lists} are
1135 1135
1136@example 1136@example
1137@group 1137@group
1138(setq x (list 1 2 3)) 1138(setq x (list 1 2 3)) ; @r{Create a mutable list.}
1139 @result{} (1 2 3) 1139 @result{} (1 2 3)
1140@end group 1140@end group
1141@group 1141@group
1142(nconc x '(4 5)) 1142(nconc x '(4 5)) ; @r{Modify the list's tail to be a constant list.}
1143 @result{} (1 2 3 4 5) 1143 @result{} (1 2 3 4 5)
1144@end group 1144@end group
1145@group 1145@group
@@ -1267,9 +1267,7 @@ after those elements. For example:
1267 1267
1268@example 1268@example
1269@group 1269@group
1270(equal 1270(delq 'a '(a b c)) @equiv{} (cdr '(a b c))
1271 (delq 'a (list 'a 'b 'c))
1272 (cdr (list 'a 'b 'c)))
1273@end group 1271@end group
1274@end example 1272@end example
1275 1273
diff --git a/doc/lispref/sequences.texi b/doc/lispref/sequences.texi
index 62d60156fbf..1cb0d05cc7b 100644
--- a/doc/lispref/sequences.texi
+++ b/doc/lispref/sequences.texi
@@ -183,11 +183,11 @@ for other ways to copy sequences.
183 183
184@example 184@example
185@group 185@group
186(setq bar (list 1 2)) 186(setq bar (list 1 2)) ; @r{Create a mutable list.}
187 @result{} (1 2) 187 @result{} (1 2)
188@end group 188@end group
189@group 189@group
190(setq x (vector 'foo bar)) 190(setq x (vector 'foo bar)) ; @r{Create a mutable vector.}
191 @result{} [foo (1 2)] 191 @result{} [foo (1 2)]
192@end group 192@end group
193@group 193@group
@@ -278,7 +278,7 @@ Unlike @code{reverse} the original @var{sequence} may be modified.
278 278
279@example 279@example
280@group 280@group
281(setq x (list 'a 'b 'c)) 281(setq x (list 'a 'b 'c)) ; @r{Create a mutable list.}
282 @result{} (a b c) 282 @result{} (a b c)
283@end group 283@end group
284@group 284@group
@@ -320,7 +320,7 @@ presented graphically:
320 For the vector, it is even simpler because you don't need setq: 320 For the vector, it is even simpler because you don't need setq:
321 321
322@example 322@example
323(setq x (copy-sequence [1 2 3 4])) 323(setq x (copy-sequence [1 2 3 4])) ; @r{Create a mutable vector.}
324 @result{} [1 2 3 4] 324 @result{} [1 2 3 4]
325(nreverse x) 325(nreverse x)
326 @result{} [4 3 2 1] 326 @result{} [4 3 2 1]
@@ -374,7 +374,7 @@ appears in a different position in the list due to the change of
374 374
375@example 375@example
376@group 376@group
377(setq nums (list 1 3 2 6 5 4 0)) 377(setq nums (list 1 3 2 6 5 4 0)) ; @r{Create a mutable list.}
378 @result{} (1 3 2 6 5 4 0) 378 @result{} (1 3 2 6 5 4 0)
379@end group 379@end group
380@group 380@group
@@ -1228,7 +1228,7 @@ This function sets the @var{index}th element of @var{array} to be
1228 1228
1229@example 1229@example
1230@group 1230@group
1231(setq w (vector 'foo 'bar 'baz)) 1231(setq w (vector 'foo 'bar 'baz)) ; @r{Create a mutable vector.}
1232 @result{} [foo bar baz] 1232 @result{} [foo bar baz]
1233(aset w 0 'fu) 1233(aset w 0 'fu)
1234 @result{} fu 1234 @result{} fu
@@ -1262,6 +1262,7 @@ each element of @var{array} is @var{object}. It returns @var{array}.
1262 1262
1263@example 1263@example
1264@group 1264@group
1265;; @r{Create a mutable vector and then fill it with zeros.}
1265(setq a (copy-sequence [a b c d e f g])) 1266(setq a (copy-sequence [a b c d e f g]))
1266 @result{} [a b c d e f g] 1267 @result{} [a b c d e f g]
1267(fillarray a 0) 1268(fillarray a 0)
@@ -1270,6 +1271,7 @@ a
1270 @result{} [0 0 0 0 0 0 0] 1271 @result{} [0 0 0 0 0 0 0]
1271@end group 1272@end group
1272@group 1273@group
1274;; @r{Create a mutable string and then fill it with "-".}
1273(setq s (copy-sequence "When in the course")) 1275(setq s (copy-sequence "When in the course"))
1274 @result{} "When in the course" 1276 @result{} "When in the course"
1275(fillarray s ?-) 1277(fillarray s ?-)