bug#71047: [PATCH] doc: Recommend alist-copy instead of list-copy.
Ludovic Courtès <[email protected]> Sat, 26 Oct 2024 19:33:42 +0200
| Newsgroups | gmane.lisp.guile.bugs |
|---|---|
| Message-ID | <[email protected]> |
Tomas Volf <[email protected]> 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!