Subject: bug#71047: closed (Re: bug#71047: [PATCH] doc: Recommend alist-copy instead of list-copy.)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 26 Oct 2024 17:35:02 +0000

Your bug report

#71047: [PATCH] doc: Recommend alist-copy instead of list-copy.

which was filed against the guile package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
71047: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71047
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#71047: [PATCH] doc: Recommend alist-copy instead of list-copy.
From: Ludovic Courtès <[email-masked]>
To: Tomas Volf <[email-masked]>
Cc: [email-masked]
Date: Sat, 26 Oct 2024 19:33:42 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Tomas Volf <[email-masked]> skribis:

> 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'.

Applied, thanks!

Subject: [PATCH] doc: Recommend alist-copy instead of list-copy.
From: Tomas Volf <[email-masked]>
To: [email-masked]
Cc: Tomas Volf <[email-masked]>
Date: Sun, 19 May 2024 00:47:07 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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'.
---
 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 3b9933d97..81552dec3 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -9509,7 +9509,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.
 
 @deffn {Scheme Procedure} acons key value alist
-- 
2.41.0