From unknown Mon Aug 18 04:09:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7088: `copy-tree' of a vector copy sharing structure.with original Resent-From: MON KEY Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Sep 2010 05:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 7088 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 7088@debbugs.gnu.org Cc: 7083@debbugs.gnu.org, Andreas Schwab X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.128521956430616 (code B ref -1); Thu, 23 Sep 2010 05:27:02 +0000 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: From: MON KEY 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-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 unknown Mon Aug 18 04:09:10 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: MON KEY Subject: bug#7088: closed (Re: bug#7088: `copy-tree' of a vector copy sharing structure.with original) Message-ID: References: X-Gnu-PR-Message: they-closed 7088 X-Gnu-PR-Package: emacs Reply-To: 7088@debbugs.gnu.org Date: Thu, 23 Sep 2010 08:46:03 +0000 Content-Type: multipart/mixed; boundary="----------=_1285231563-4265-1" This is a multi-part message in MIME format... ------------=_1285231563-4265-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #7088: `copy-tree' of a vector copy sharing structure.with original which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 7088@debbugs.gnu.org. --=20 7088: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D7088 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1285231563-4265-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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." ------------=_1285231563-4265-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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\ ------------=_1285231563-4265-1-- From unknown Mon Aug 18 04:09:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7088: `copy-tree' of a vector copy sharing structure.with original Resent-From: David De La Harpe Golden Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Sep 2010 20:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7088 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: MON KEY Cc: 7083@debbugs.gnu.org, 7088@debbugs.gnu.org Received: via spool by 7088-submit@debbugs.gnu.org id=B7088.128527433825359 (code B ref 7088); Thu, 23 Sep 2010 20:39:02 +0000 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 References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.7 (--) 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 unknown Mon Aug 18 04:09:10 2025 X-Loop: help-debbugs@gnu.org Subject: bug#7088: `copy-tree' of a vector copy sharing structure.with original Resent-From: MON KEY Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Sep 2010 05:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7088 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: David De La Harpe Golden Cc: 7088@debbugs.gnu.org, Andreas Schwab , Stefan Monnier Received: via spool by 7088-submit@debbugs.gnu.org id=B7088.12853053985343 (code B ref 7088); Fri, 24 Sep 2010 05:17:02 +0000 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: From: MON KEY Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -3.1 (---) 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\