unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: MON KEY <monkey@sandpframing.com>
To: David De La Harpe Golden <david@harpegolden.net>
Cc: 7088@debbugs.gnu.org, Andreas Schwab <schwab@linux-m68k.org>
Subject: bug#7088: `copy-tree' of a vector copy sharing structure.with original
Date: Fri, 24 Sep 2010 01:19:13 -0400	[thread overview]
Message-ID: <AANLkTimec8s=6eu0=MQy7xGc1gwsKr-x1FD+4H_QK=y5@mail.gmail.com> (raw)
In-Reply-To: <4C9BBB7A.2060004@harpegolden.net>

On Thu, Sep 23, 2010 at 4:41 PM, David De La Harpe Golden
<david@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\





      reply	other threads:[~2010-09-24  5:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-23  5:28 bug#7088: `copy-tree' of a vector copy sharing structure.with original MON KEY
2010-09-23  8:47 ` bug#7083: " Andreas Schwab
2010-09-23 20:41 ` David De La Harpe Golden
2010-09-24  5:19   ` MON KEY [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTimec8s=6eu0=MQy7xGc1gwsKr-x1FD+4H_QK=y5@mail.gmail.com' \
    --to=monkey@sandpframing.com \
    --cc=7088@debbugs.gnu.org \
    --cc=david@harpegolden.net \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).