mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
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>
This commit is contained in:
parent
a0368a6120
commit
1c093d8bc4
1 changed files with 1 additions and 1 deletions
|
@ -9510,7 +9510,7 @@ difference to you.
|
||||||
If you need to keep the old value of an association list in a form
|
If you need to keep the old value of an association list in a form
|
||||||
independent from the list that results from modification by
|
independent from the list that results from modification by
|
||||||
@code{acons}, @code{assq-set!}, @code{assv-set!} or @code{assoc-set!},
|
@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.
|
it.
|
||||||
|
|
||||||
@rnindex acons
|
@rnindex acons
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue