From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joseph Turner Newsgroups: gmane.emacs.devel Subject: Re: Optionally use copy-tree for cl struct copier Date: Sun, 10 Sep 2023 11:51:06 -0700 Message-ID: <87y1hdluw4.fsf@breatheoutbreathe.in> References: <8734zln9tp.fsf@breatheoutbreathe.in> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9988"; mail-complaints-to="usenet@ciao.gmane.io" To: Emacs Devel Mailing List , Adam Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Sep 10 21:01:09 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qfPgC-0002TL-MV for ged-emacs-devel@m.gmane-mx.org; Sun, 10 Sep 2023 21:01:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfPfH-0001e2-CF; Sun, 10 Sep 2023 15:00:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qfPbn-00006T-G7 for emacs-devel@gnu.org; Sun, 10 Sep 2023 14:56:36 -0400 Original-Received: from out-222.mta1.migadu.com ([2001:41d0:203:375::de]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qfPbl-0003qm-7q for emacs-devel@gnu.org; Sun, 10 Sep 2023 14:56:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1694372190; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qkC8XdPtAUUEpPw8RQj+587H74dujm49iEgXhkUVRcQ=; b=Tzv4OPzShJntAzRt5cwHEaqh7zo31qOeNkbqfshZBjGmLlxVjUaoBZe6xGZPA7ziK1ZFRl xiCJ/WH2GV++RX/VKEAMkvUNC/aTn7tNGsxN/3E6MXV5e8CGRXRW41IUF1xGSkQOAHhAOC ZH7cU3IH9qGspuR6f4yACcWL+Oxk2sU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-reply-to: <8734zln9tp.fsf@breatheoutbreathe.in> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:203:375::de; envelope-from=joseph@breatheoutbreathe.in; helo=out-222.mta1.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 10 Sep 2023 15:00:08 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310446 Archived-At: Joseph Turner 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)))