* Optionally use copy-tree for cl struct copier
@ 2023-09-10 18:42 Joseph Turner
2023-09-10 18:51 ` Joseph Turner
0 siblings, 1 reply; 4+ messages in thread
From: Joseph Turner @ 2023-09-10 18:42 UTC (permalink / raw)
To: Emacs Devel Mailing List; +Cc: Adam Porter
Would you be open to adding an option to cl-defstruct that would alias
the copier function to (lambda (obj) (copy-tree obj t)) instead of
copy-sequence?
If so, what kind of syntax would you want? Maybe something like
(cl-defstruct (foo (:copier nil :recursive t)) a b c)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Optionally use copy-tree for cl struct copier
2023-09-10 18:42 Optionally use copy-tree for cl struct copier Joseph Turner
@ 2023-09-10 18:51 ` Joseph Turner
2023-09-10 18:58 ` Joseph Turner
2023-09-10 18:58 ` Joseph Turner
0 siblings, 2 replies; 4+ messages in thread
From: Joseph Turner @ 2023-09-10 18:51 UTC (permalink / raw)
To: Emacs Devel Mailing List, Adam Porter
Joseph Turner <joseph@breatheoutbreathe.in> writes:
> Would you be open to adding an option to cl-defstruct that would alias
> the copier function to (lambda (obj) (copy-tree obj t)) instead of
> copy-sequence?
>
> If so, what kind of syntax would you want? Maybe something like
>
> (cl-defstruct (foo (:copier nil :recursive t)) a b c)
Perhaps instead making copier always recursive, we could instead set the
copier to a separate function which optionally recurses:
(cl-defun copy-foo (obj &key recursive)
"Copy OBJ with `copy-sequence'. If RECURSIVE, use `copy-tree'."
(if recursive
(copy-tree obj t)
(copy-sequence obj)))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Optionally use copy-tree for cl struct copier
2023-09-10 18:51 ` Joseph Turner
2023-09-10 18:58 ` Joseph Turner
@ 2023-09-10 18:58 ` Joseph Turner
1 sibling, 0 replies; 4+ messages in thread
From: Joseph Turner @ 2023-09-10 18:58 UTC (permalink / raw)
To: Emacs Devel Mailing List, Adam Porter
Joseph Turner <joseph@breatheoutbreathe.in> writes:
> Joseph Turner <joseph@breatheoutbreathe.in> writes:
>
>> Would you be open to adding an option to cl-defstruct that would alias
>> the copier function to (lambda (obj) (copy-tree obj t)) instead of
>> copy-sequence?
>>
>> If so, what kind of syntax would you want? Maybe something like
>>
>> (cl-defstruct (foo (:copier nil :recursive t)) a b c)
>
> Perhaps instead making copier always recursive, we could instead set the
> copier to a separate function which optionally recurses:
>
> (cl-defun copy-foo (obj &key recursive)
> "Copy OBJ with `copy-sequence'. If RECURSIVE, use `copy-tree'."
> (if recursive
> (copy-tree obj t)
> (copy-sequence obj)))
... but this may be useless, since you can just use copy-tree.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Optionally use copy-tree for cl struct copier
2023-09-10 18:51 ` Joseph Turner
@ 2023-09-10 18:58 ` Joseph Turner
2023-09-10 18:58 ` Joseph Turner
1 sibling, 0 replies; 4+ messages in thread
From: Joseph Turner @ 2023-09-10 18:58 UTC (permalink / raw)
To: Emacs Devel Mailing List, Adam Porter
Joseph Turner <joseph@breatheoutbreathe.in> writes:
> Joseph Turner <joseph@breatheoutbreathe.in> writes:
>
>> Would you be open to adding an option to cl-defstruct that would alias
>> the copier function to (lambda (obj) (copy-tree obj t)) instead of
>> copy-sequence?
>>
>> If so, what kind of syntax would you want? Maybe something like
>>
>> (cl-defstruct (foo (:copier nil :recursive t)) a b c)
>
> Perhaps instead making copier always recursive, we could instead set the
> copier to a separate function which optionally recurses:
>
> (cl-defun copy-foo (obj &key recursive)
> "Copy OBJ with `copy-sequence'. If RECURSIVE, use `copy-tree'."
> (if recursive
> (copy-tree obj t)
> (copy-sequence obj)))
... but this may be useless, since you can just use copy-tree.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-10 18:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-10 18:42 Optionally use copy-tree for cl struct copier Joseph Turner
2023-09-10 18:51 ` Joseph Turner
2023-09-10 18:58 ` Joseph Turner
2023-09-10 18:58 ` Joseph Turner
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).