summaryrefslogtreecommitdiff
path: root/doc/ref/libguile-program.texi
diff options
context:
space:
mode:
authorTomas Volf <~@wolfsden.cz>2024-05-19 00:47:07 +0200
committerLudovic Courtès <ludo@gnu.org>2024-10-26 19:45:11 +0200
commit1c093d8bc4b74bd7392f1520c2135d8ba40a2735 (patch)
treeaaf05d0957a423a0db4fbe3afddfbc0d5124c269 /doc/ref/libguile-program.texi
parenta0368a61204e02b892069b5a7937b0c3900215ae (diff)
downloadguile-1c093d8bc4b74bd7392f1520c2135d8ba40a2735.tar.gz
doc: Recommend alist-copy instead of list-copy.
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'. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'doc/ref/libguile-program.texi')
0 files changed, 0 insertions, 0 deletions