unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: emacs-devel@gnu.org
Subject: Re: New function safe-copy-tree.
Date: Tue, 07 Mar 2023 14:12:37 +0200	[thread overview]
Message-ID: <83cz5k7oay.fsf@gnu.org> (raw)
In-Reply-To: <ZAZXpdm5QzPFX6Pb@ACM> (message from Alan Mackenzie on Mon, 6 Mar 2023 21:14:13 +0000)

> Date: Mon, 6 Mar 2023 21:14:13 +0000
> From: Alan Mackenzie <acm@muc.de>
> 
> In order to fix bug #61962, I'm intending to introduce a new function
> safe-copy-tree in subr.el.  It is like copy-tree, except it works with
> circular lists as well as normal ones.
> 
> My current implementation looks like this:

This is for master, right?

> +(defvar safe-copy-tree--seen nil
> +  "A hash table for conses/vectors/records already seen by safe-copy-tree-1.
> +It's key is a cons or vector/record seen by the algorithm, and its value is
   ^^^^
"Its"

> +(defun safe-copy-tree (tree &optional vecp)
> +  "Make a copy of TREE, taking circular structure into account.
> +If TREE is a cons cell, this recursively copies both its car and its cdr.
> +Contrast to `copy-sequence', which copies only along the cdrs.  With second
> +argument VECP, this copies vectors and records as well as conses."
> +  (setq safe-copy-tree--seen (make-hash-table :test #'eq))
> +  (safe-copy-tree--1 tree vecp))

Where is this hash table deleted?

And shouldn't this be inside unwind-protect, so that you could be sure
the hash table is always reset to nil when the processing is done?



  reply	other threads:[~2023-03-07 12:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06 21:14 New function safe-copy-tree Alan Mackenzie
2023-03-07 12:12 ` Eli Zaretskii [this message]
2023-03-07 13:37 ` Mattias Engdegård
2023-03-07 15:52   ` Alan Mackenzie

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/emacs/

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

  git send-email \
    --in-reply-to=83cz5k7oay.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).