GNU bug report logs -
#71047
[PATCH] doc: Recommend alist-copy instead of list-copy.
Previous Next
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
Message #10 received at 71047-done <at> debbugs.gnu.org (full text, mbox):
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!
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.