[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26629: 25.1.50; Feature-request: Structure-preserving copying of seq
From: |
Stefan Monnier |
Subject: |
bug#26629: 25.1.50; Feature-request: Structure-preserving copying of sequences |
Date: |
Fri, 13 May 2022 13:47:53 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
> I haven't looked closely at the code, but this is functionality that I
> vaguely remember having been requested before, and I don't think Emacs
> has it yet? (But I may be wrong about that.)
> I've added Stefan to the CCs; perhaps he has some comments.
My opinion is rather negative: IMO `copy-tree` itself is a bad function
in the sense that it's (almost) never really right, IOW most uses of
`copy-tree` are fundamentally quick hacks which happen to work most of
the time because the details of when to recurse and when not to very
rarely map exactly to "recurse on `cons` and only `cons`".
So rather than `copy-tree*` I'd rather see some kind of generic
`deep-copy` function which takes a (or some) parameter(s) that indicates
when (and potentially how) to copy/recurse each of the elements (where
`deep-copy`s job would thus be mainly to take care of maintaining the
hash-map and maybe using an explicit stack to avoid deep recursion).
Stefan