GNU bug report logs - #71047
[PATCH] doc: Recommend alist-copy instead of list-copy.

Previous Next

Package: guile;

Reported by: Tomas Volf <~@wolfsden.cz>

Date: Sat, 18 May 2024 22:48:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Tomas Volf <~@wolfsden.cz>
Subject: bug#71047: closed (Re: bug#71047: [PATCH] doc: Recommend
 alist-copy instead of list-copy.)
Date: Sat, 26 Oct 2024 17:35:02 +0000
[Message part 1 (text/plain, inline)]
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 71047 <at> debbugs.gnu.org.

-- 
71047: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71047
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Ludovic Courtès <ludo <at> gnu.org>
To: Tomas Volf <~@wolfsden.cz>
Cc: 71047-done <at> debbugs.gnu.org
Subject: Re: bug#71047: [PATCH] doc: Recommend alist-copy instead of list-copy.
Date: Sat, 26 Oct 2024 19:33:42 +0200
Tomas Volf <~@wolfsden.cz> 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!

[Message part 3 (message/rfc822, inline)]
From: Tomas Volf <~@wolfsden.cz>
To: bug-guile <at> gnu.org
Cc: Tomas Volf <~@wolfsden.cz>
Subject: [PATCH] doc: Recommend alist-copy instead of list-copy.
Date: Sun, 19 May 2024 00:47:07 +0200
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




This bug report was last modified 300 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.