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!