unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Tomas Volf <~@wolfsden.cz>
Cc: 71047-done@debbugs.gnu.org
Subject: bug#71047: [PATCH] doc: Recommend alist-copy instead of list-copy.
Date: Sat, 26 Oct 2024 19:33:42 +0200	[thread overview]
Message-ID: <87r082u5u1.fsf@gnu.org> (raw)
In-Reply-To: <20240518224707.28233-1-~@wolfsden.cz> (Tomas Volf's message of "Sun, 19 May 2024 00:47:07 +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!





      reply	other threads:[~2024-10-26 17:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-18 22:47 bug#71047: [PATCH] doc: Recommend alist-copy instead of list-copy Tomas Volf
2024-10-26 17:33 ` Ludovic Courtès [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r082u5u1.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=71047-done@debbugs.gnu.org \
    --cc=~@wolfsden.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).