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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 71047 in the body.
You can then email your comments to 71047 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#71047; Package guile. (Sat, 18 May 2024 22:48:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tomas Volf <~@wolfsden.cz>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sat, 18 May 2024 22:48:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

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





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Sat, 26 Oct 2024 17:35:02 GMT) Full text and rfc822 format available.

Notification sent to Tomas Volf <~@wolfsden.cz>:
bug acknowledged by developer. (Sat, 26 Oct 2024 17:35:02 GMT) Full text and rfc822 format available.

Message #10 received at 71047-done <at> debbugs.gnu.org (full text, mbox):

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!




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 24 Nov 2024 12:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 34 days ago.

Previous Next


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