unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Denis Bueno <dbueno@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: sharing list structure
Date: Thu, 24 Mar 2005 19:35:50 -0500	[thread overview]
Message-ID: <6dbd4d000503241635410430b0@mail.gmail.com> (raw)
In-Reply-To: <E1DEcfg-0002gI-00@lab45.ma.utexas.edu>

On Thu, 24 Mar 2005 18:27:28 -0600, Joe Corneli
<jcorneli@math.utexas.edu> wrote:
>    The `append' doesn't alter the structure of the list A.
> 
>      (defvar *foo* (list 1 2 3))
>      (append *foo* (list 4 5 6))
>      *foo* => (1 2 3)
> 
>    Hence, the result of append doesn't alter A's structure.
> 
> Note the `setq' above, which make it look an awful lot like the
> structure of A *is* being modified.  I mean, it comes out as a
> different list --

The setq modifies what the value of the symbol A is - it's destructive
in that sense. After the setq, instead of being (1 2 3), A's value to
the list (1 2 3 4). But it's a different list (in memory) from its
former value.

>    So, just restrict yourself to destructive operations on A - like
>    setcdr, setcar, etc. - and you'll be set. Just note that A will always
>    have to be the "tail" part of B.
> 
> OK, I think I've got the idea now.  But still, I'm surprised that `setq'
> is not among the list of "destructive functions".  What's that about?

Like I said, the difference is in just _what_ it's destructively
modifying. In the case above, it destructively modifies the value of
the symbol A (see `symbol-value'), not the structure of the list whose
head cons cell is the value of the symbol A (which is just a more
precise way of saying "the list A").


-- 
Denis Bueno
PGP: http://pgp.mit.edu:11371/pks/lookup?search=0xA1B51B4B&op=index

  reply	other threads:[~2005-03-25  0:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-24 23:48 sharing list structure Joe Corneli
2005-03-25  0:17 ` Denis Bueno
2005-03-25  0:27   ` Joe Corneli
2005-03-25  0:35     ` Denis Bueno [this message]
     [not found]   ` <mailman.176.1111711460.28103.help-gnu-emacs@gnu.org>
2005-03-25  1:21     ` Thien-Thi Nguyen
2005-03-26 23:58     ` Stefan Monnier
     [not found] <mailman.173.1111709565.28103.help-gnu-emacs@gnu.org>
2005-03-25  1:01 ` rgb
2005-03-25  1:42   ` Joe Corneli
     [not found]   ` <mailman.182.1111716692.28103.help-gnu-emacs@gnu.org>
2005-03-25  5:44     ` rgb
2005-03-25  5:49       ` rgb
2005-03-25  6:08       ` Joe Corneli

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=6dbd4d000503241635410430b0@mail.gmail.com \
    --to=dbueno@gmail.com \
    --cc=help-gnu-emacs@gnu.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.
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).