[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Optionally use copy-tree for cl struct copier
From: |
Joseph Turner |
Subject: |
Re: Optionally use copy-tree for cl struct copier |
Date: |
Sun, 10 Sep 2023 11:58:11 -0700 |
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.