From unknown Mon Aug 18 17:58:13 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#7088 <7088@debbugs.gnu.org> To: bug#7088 <7088@debbugs.gnu.org> Subject: Status: `copy-tree' of a vector copy sharing structure.with original Reply-To: bug#7088 <7088@debbugs.gnu.org> Date: Tue, 19 Aug 2025 00:58:13 +0000 retitle 7088 `copy-tree' of a vector copy sharing structure.with original reassign 7088 emacs submitter 7088 MON KEY severity 7088 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 23 01:26:04 2010 Received: (at submit) by debbugs.gnu.org; 23 Sep 2010 05:26:04 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyeJn-0007xg-9f for submit@debbugs.gnu.org; Thu, 23 Sep 2010 01:26:03 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyeJm-0007xF-B8 for submit@debbugs.gnu.org; Thu, 23 Sep 2010 01:26:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OyeMI-0000b1-0q for submit@debbugs.gnu.org; Thu, 23 Sep 2010 01:28:39 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([199.232.76.165]:59969) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyeMH-0000av-VM for submit@debbugs.gnu.org; Thu, 23 Sep 2010 01:28:37 -0400 Received: from [140.186.70.92] (port=43025 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OyeMG-0005t8-RB for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2010 01:28:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OyeMF-0000ac-MM for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2010 01:28:36 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:51927) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyeMF-0000aL-B7 for bug-gnu-emacs@gnu.org; Thu, 23 Sep 2010 01:28:35 -0400 Received: by wyb36 with SMTP id 36so1547974wyb.0 for ; Wed, 22 Sep 2010 22:28:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.93.73 with SMTP id k51mr1044542wef.8.1285219713822; Wed, 22 Sep 2010 22:28:33 -0700 (PDT) Received: by 10.216.67.195 with HTTP; Wed, 22 Sep 2010 22:28:33 -0700 (PDT) Date: Thu, 23 Sep 2010 01:28:33 -0400 X-Google-Sender-Auth: cWrqkx0fa1Me52Wbs8an2Y2NH0E Message-ID: Subject: `copy-tree' of a vector copy sharing structure.with original From: MON KEY To: bug-gnu-emacs@gnu.org Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -5.1 (-----) X-Debbugs-Envelope-To: submit Cc: 7083@debbugs.gnu.org, Andreas Schwab X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.1 (-----) When copy-tree copies vectors the copy shares structure with the original. This is unlike the behavior of copy-tree on a list of lists: (let ((orig '((a b) (c d) (e f) (g h))) new-cp) (setq new-cp (copy-tree orig)) (equal (elt (prog1 orig (setf (car new-cp) "bubba")) 0) '(a b))) ;=> t (let ((orig [[a b] [c d] [e f] [g h]]) new-cp) (setq new-cp (copy-tree orig)) (string-equal (aref (prog1 orig (aset new-cp 0 "bubba")) 0) "bubba")) ;=> t Shouldn't idx 0 of the orig tree still be [a b]? Note This bug _should_ prob. have stayed with Bug7083 but that bug report was prematurely closed. -- /s_P\ From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 23 04:45:05 2010 Received: (at 7088-done) by debbugs.gnu.org; 23 Sep 2010 08:45:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyhQO-00016N-VQ for submit@debbugs.gnu.org; Thu, 23 Sep 2010 04:45:05 -0400 Received: from mail-out.m-online.net ([212.18.0.9]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyhQL-00015j-0S; Thu, 23 Sep 2010 04:45:01 -0400 Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 4E3881C159E1; Thu, 23 Sep 2010 10:47:37 +0200 (CEST) Received: from hase.home (ppp-88-217-115-11.dynamic.mnet-online.de [88.217.115.11]) by mail.mnet-online.de (Postfix) with ESMTP id CA8521C00314; Thu, 23 Sep 2010 10:47:36 +0200 (CEST) From: Andreas Schwab To: MON KEY Subject: Re: bug#7088: `copy-tree' of a vector copy sharing structure.with original References: X-Yow: Go on, EMOTE! I was RAISED on thought balloons!! Date: Thu, 23 Sep 2010 10:47:36 +0200 In-Reply-To: (MON KEY's message of "Thu, 23 Sep 2010 01:28:33 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 7088-done Cc: 7083@debbugs.gnu.org, 7088-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) MON KEY writes: > When copy-tree copies vectors the copy shares structure with the original. Works as documented. A vector is not a cons cell. If TREE is a cons cell, this recursively copies both its car and its cdr. ^^^^^^^^^ Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Thu Sep 23 16:38:58 2010 Received: (at 7088) by debbugs.gnu.org; 23 Sep 2010 20:38:58 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OysZF-0006aw-2I for submit@debbugs.gnu.org; Thu, 23 Sep 2010 16:38:57 -0400 Received: from harpegolden.net ([65.99.215.13]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OysZC-0006ak-B6; Thu, 23 Sep 2010 16:38:54 -0400 Received: from [87.198.54.160] (87-198-54-160.ptr.magnet.ie [87.198.54.160]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "David De La Harpe Golden", Issuer "David De La Harpe Golden Personal CA rev 3" (verified OK)) by harpegolden.net (Postfix) with ESMTPSA id 8F5CA684DE; Thu, 23 Sep 2010 21:41:27 +0100 (IST) Message-ID: <4C9BBB7A.2060004@harpegolden.net> Date: Thu, 23 Sep 2010 21:41:30 +0100 From: David De La Harpe Golden User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100913 Icedove/3.0.7 MIME-Version: 1.0 To: MON KEY Subject: Re: bug#7088: `copy-tree' of a vector copy sharing structure.with original References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.7 (--) X-Debbugs-Envelope-To: 7088 Cc: 7083@debbugs.gnu.org, 7088@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.7 (--) On 23/09/10 06:28, MON KEY wrote: > (let ((orig [[a b] [c d] [e f] [g h]]) > new-cp) > (setq new-cp (copy-tree orig)) Some people would have at least considered a quick C-h f copy-tree before filing a bug? You're missing the VECP arg to emacs lisp copy-tree. Without that, emacs lisp copy-tree is, much like common lisp copy-tree, documented to copy trees of _conses_. Conses do of course look pretty like 2 element vectors, but they are a separate datatype in emacs lisp. ELISP> (let ((orig [[a b] [c d] [e f] [g h]]) new-cp) (setq new-cp (copy-tree orig t)) (string-equal (aref (prog1 orig (aset new-cp 0 "bubba")) 0) "bubba")) *** Eval error *** Wrong type argument: stringp, [a b] From debbugs-submit-bounces@debbugs.gnu.org Fri Sep 24 01:16:38 2010 Received: (at 7088) by debbugs.gnu.org; 24 Sep 2010 05:16:38 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oz0eD-0001O8-Ma for submit@debbugs.gnu.org; Fri, 24 Sep 2010 01:16:37 -0400 Received: from mail-wy0-f172.google.com ([74.125.82.172]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oz0eC-0001O3-3x for 7088@debbugs.gnu.org; Fri, 24 Sep 2010 01:16:36 -0400 Received: by wyi11 with SMTP id 11so2187276wyi.3 for <7088@debbugs.gnu.org>; Thu, 23 Sep 2010 22:19:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.44.141 with SMTP id n13mr1677968web.16.1285305554686; Thu, 23 Sep 2010 22:19:14 -0700 (PDT) Received: by 10.216.67.195 with HTTP; Thu, 23 Sep 2010 22:19:13 -0700 (PDT) In-Reply-To: <4C9BBB7A.2060004@harpegolden.net> References: <4C9BBB7A.2060004@harpegolden.net> Date: Fri, 24 Sep 2010 01:19:13 -0400 X-Google-Sender-Auth: VtHCrS-VGo4YI1V4li1yeULyxN8 Message-ID: Subject: Re: bug#7088: `copy-tree' of a vector copy sharing structure.with original From: MON KEY To: David De La Harpe Golden Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -3.1 (---) X-Debbugs-Envelope-To: 7088 Cc: 7088@debbugs.gnu.org, Andreas Schwab , Stefan Monnier X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -3.1 (---) On Thu, Sep 23, 2010 at 4:41 PM, David De La Harpe Golden wrote: > On 23/09/10 06:28, MON KEY wrote: >> >> (let ((orig [[a b] [c d] [e f] [g h]]) >> new-cp) >> (setq new-cp (copy-tree orig)) > > Some people would have at least considered a quick C-h f copy-tree > before filing a bug? > > You're missing the VECP arg to emacs lisp copy-tree. > (let ((orig '((a . b) [c d] [e f] [g h])) new-cp) (setq new-cp (copy-tree orig)) (string-equal (elt (elt (prog1 orig (aset (elt new-cp 1) 0 "bubba")) 1) 0) "bubba")) ;=> t The VECP arg wasn't needed in order to copy the vector only to prevent the copy from sharing structure... This isn't at all clear in the docs. (let ((orig [(a . b) [c d] [e f] [g h]]) new-cp) (setq new-cp (copy-tree orig t)) (string-equal (cdr (elt (prog1 orig (setf (cdr (elt new-cp 0)) "bubba")) 0)) "bubba")) ;=> nil > Without that, emacs lisp copy-tree is, much like common lisp copy-tree, > documented to copy trees of _conses_. Conses do of course look pretty like > 2 element vectors, but they are a separate datatype in emacs lisp. > OK. Thank you for taking the time to clarify this. I read the doc 3 or 4 times and glanced at the sources and it wasn't clear what the intent of the VECP (a non-predicate BTW) is intended to accomplish. Maybe a copy-vector would be better instead of lumping the datatypes together. Anyhow, sorry for the noise. -- /s_P\ From unknown Mon Aug 18 17:58:13 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 22 Oct 2010 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator