GNU bug report logs - #7083
Why is `copy-tree's symbol-plist carrying side-effect-free error-free?

Previous Next

Package: emacs;

Reported by: MON KEY <monkey <at> sandpframing.com>

Date: Wed, 22 Sep 2010 06:30:02 UTC

Severity: normal

Done: Andreas Schwab <schwab <at> linux-m68k.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 7083 in the body.
You can then email your comments to 7083 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7083; Package emacs. (Wed, 22 Sep 2010 06:30:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to MON KEY <monkey <at> sandpframing.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 22 Sep 2010 06:30:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: MON KEY <monkey <at> sandpframing.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Why is `copy-tree's symbol-plist carrying side-effect-free error-free?
Date: Wed, 22 Sep 2010 02:31:41 -0400
Why is `copy-tree' side-effect-free error-free?

(symbol-plist 'copy-tree)
=> (side-effect-free error-free)

It (potentially) `nconc's `nreverse's and `aset's the TREE arg recursively.

At revno: 45675 `copy-tree' was moved into subr.el from cl.el

,----
|
| committer: Colin Walters <walters <at> gnu.org>
| timestamp: Sat 2002-06-08 20:48:15 +0000
| message:
|   (copy-list): Moved here from cl.el.
|   (copy-tree): Renamed here from `cl-copy-tree' in cl.el.
|
`----

--
/s_P\




Reply sent to Andreas Schwab <schwab <at> linux-m68k.org>:
You have taken responsibility. (Wed, 22 Sep 2010 21:34:01 GMT) Full text and rfc822 format available.

Notification sent to MON KEY <monkey <at> sandpframing.com>:
bug acknowledged by developer. (Wed, 22 Sep 2010 21:34:02 GMT) Full text and rfc822 format available.

Message #10 received at 7083-done <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 7083-done <at> debbugs.gnu.org
Subject: Re: bug#7083: Why is `copy-tree's symbol-plist carrying
	side-effect-free error-free?
Date: Wed, 22 Sep 2010 23:35:56 +0200
MON KEY <monkey <at> sandpframing.com> writes:

> It (potentially) `nconc's `nreverse's and `aset's the TREE arg recursively.

Only the copy.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7083; Package emacs. (Thu, 23 Sep 2010 05:22:01 GMT) Full text and rfc822 format available.

Message #13 received at 7083 <at> debbugs.gnu.org (full text, mbox):

From: MON KEY <monkey <at> sandpframing.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 7083 <at> debbugs.gnu.org
Subject: Re: bug#7083: Why is `copy-tree's symbol-plist carrying
	side-effect-free error-free?
Date: Thu, 23 Sep 2010 01:23:44 -0400
On Wed, Sep 22, 2010 at 5:35 PM, Andreas Schwab <schwab <at> linux-m68k.org> wrote:
> MON KEY <monkey <at> sandpframing.com> writes:
>
>> It (potentially) `nconc's `nreverse's and `aset's the TREE arg recursively.
>
> Only the copy.
>

Only for the copy of a list.

Why has this bug been marked done?

When copy-tree copies vectors they share structure.

(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]?

If not, it should be documented that when copy-tree copies vectors the
"copy" will share structure just as with `copy-sequence'.

Regardless, simply marking the bug report as done with only a terse 3
word reply is obnoxious and not the least bit helpful for anyone else
referencing this report in the future, esp. as there does appear to be
a bug.


> Andreas.

--
/s_P\




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7083; Package emacs. (Thu, 23 Sep 2010 05:26:02 GMT) Full text and rfc822 format available.

Message #16 received at 7083 <at> debbugs.gnu.org (full text, mbox):

From: MON KEY <monkey <at> sandpframing.com>
To: bug-gnu-emacs <at> gnu.org
Cc: 7083 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>
Subject: `copy-tree' of a vector copy sharing structure.with original
Date: Thu, 23 Sep 2010 01:28:33 -0400
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\




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7083; Package emacs. (Thu, 23 Sep 2010 08:46:02 GMT) Full text and rfc822 format available.

Message #19 received at 7083 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 7083 <at> debbugs.gnu.org, 7088-done <at> debbugs.gnu.org
Subject: Re: bug#7088: `copy-tree' of a vector copy sharing structure.with
	original
Date: Thu, 23 Sep 2010 10:47:36 +0200
MON KEY <monkey <at> sandpframing.com> 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 <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7083; Package emacs. (Thu, 23 Sep 2010 20:39:02 GMT) Full text and rfc822 format available.

Message #22 received at 7083 <at> debbugs.gnu.org (full text, mbox):

From: David De La Harpe Golden <david <at> harpegolden.net>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 7083 <at> debbugs.gnu.org, 7088 <at> debbugs.gnu.org
Subject: Re: bug#7088: `copy-tree' of a vector copy sharing structure.with
	original
Date: Thu, 23 Sep 2010 21:41:30 +0100
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]






Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#7083; Package emacs. (Thu, 23 Sep 2010 22:18:02 GMT) Full text and rfc822 format available.

Message #25 received at 7083 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: MON KEY <monkey <at> sandpframing.com>
Cc: 7083 <at> debbugs.gnu.org, Andreas Schwab <schwab <at> linux-m68k.org>
Subject: Re: bug#7083: Why is `copy-tree's symbol-plist carrying
	side-effect-free error-free?
Date: Fri, 24 Sep 2010 00:19:47 +0200
> Why has this bug been marked done?
> When copy-tree copies vectors they share structure.

C-h f copy-tree RET documents the second (optional) argument which
affects this behavior.  So it looks perfectly correct, and documented.


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 22 Oct 2010 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.