GNU bug report logs -
#7088
`copy-tree' of a vector copy sharing structure.with original
Previous Next
Reported by: MON KEY <monkey <at> sandpframing.com>
Date: Thu, 23 Sep 2010 05:27: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 7088 in the body.
You can then email your comments to 7088 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org
:
bug#7088
; Package
emacs
.
(Thu, 23 Sep 2010 05:27:02 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
.
(Thu, 23 Sep 2010 05:27:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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\
Reply sent
to
Andreas Schwab <schwab <at> linux-m68k.org>
:
You have taken responsibility.
(Thu, 23 Sep 2010 08:46:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
MON KEY <monkey <at> sandpframing.com>
:
bug acknowledged by developer.
(Thu, 23 Sep 2010 08:46:03 GMT)
Full text and
rfc822 format available.
Message #10 received at 7088-done <at> debbugs.gnu.org (full text, mbox):
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#7088
; Package
emacs
.
(Thu, 23 Sep 2010 20:39:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 7088 <at> debbugs.gnu.org (full text, mbox):
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#7088
; Package
emacs
.
(Fri, 24 Sep 2010 05:17:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 7088 <at> debbugs.gnu.org (full text, mbox):
On Thu, Sep 23, 2010 at 4:41 PM, David De La Harpe Golden
<david <at> harpegolden.net> 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\
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 303 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.