[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 06/07: doc: Recommend alist-copy instead of list-copy.
From: |
Ludovic Courtès |
Subject: |
[Guile-commits] 06/07: doc: Recommend alist-copy instead of list-copy. |
Date: |
Sat, 26 Oct 2024 13:45:59 -0400 (EDT) |
civodul pushed a commit to branch main
in repository guile.
commit 1c093d8bc4b74bd7392f1520c2135d8ba40a2735
Author: Tomas Volf <~@wolfsden.cz>
AuthorDate: Sun May 19 00:47:07 2024 +0200
doc: Recommend alist-copy instead of list-copy.
The current recommendation of `list-copy' is not right and does not lead
to preserving the original list:
scheme@(guile-user)> (define x (list (cons 'a 1) (cons 'b 2)))
scheme@(guile-user)> (define y (list-copy x))
scheme@(guile-user)> (assq-set! y 'b 3)
$1 = ((a . 1) (b . 3))
scheme@(guile-user)> x
$2 = ((a . 1) (b . 3))
Correct approach seems to be use `alist-copy' from SRFI-1 leading to the
expected behavior of:
scheme@(guile-user)> ,use (srfi srfi-1)
scheme@(guile-user)> (define x (list (cons 'a 1) (cons 'b 2)))
scheme@(guile-user)> (define y (alist-copy x))
scheme@(guile-user)> (assq-set! y 'b 3)
$1 = ((a . 1) (b . 3))
scheme@(guile-user)> x
$2 = ((a . 1) (b . 2))
* doc/ref/api-data.texi (Adding or Setting Alist Entries): Recommend
`alist-copy'.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
doc/ref/api-data.texi | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index ae65457df..53924db01 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -9510,7 +9510,7 @@ difference to you.
If you need to keep the old value of an association list in a form
independent from the list that results from modification by
@code{acons}, @code{assq-set!}, @code{assv-set!} or @code{assoc-set!},
-use @code{list-copy} to copy the old association list before modifying
+use @code{alist-copy} to copy the old association list before modifying
it.
@rnindex acons
- [Guile-commits] branch main updated (242e8698c -> bb7154fb8), Ludovic Courtès, 2024/10/26
- [Guile-commits] 03/07: doc: Fix implication of omitting optional arguments., Ludovic Courtès, 2024/10/26
- [Guile-commits] 05/07: doc: Fix typo in FFI documentation., Ludovic Courtès, 2024/10/26
- [Guile-commits] 06/07: doc: Recommend alist-copy instead of list-copy.,
Ludovic Courtès <=
- [Guile-commits] 02/07: doc: Document #:hide., Ludovic Courtès, 2024/10/26
- [Guile-commits] 01/07: srfi-64: Accept symbols as test group names., Ludovic Courtès, 2024/10/26
- [Guile-commits] 04/07: doc: Document the peek and pk procedures., Ludovic Courtès, 2024/10/26
- [Guile-commits] 07/07: Fix build failure with GCC 14 and musl on 32-bit systems., Ludovic Courtès, 2024/10/26