emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New function safe-copy-tree.


From: Eli Zaretskii
Subject: Re: New function safe-copy-tree.
Date: Tue, 07 Mar 2023 14:12:37 +0200

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]