unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* using setq to create lists based on other lists...
@ 2018-12-02 10:53 Jean-Christophe Helary
  2018-12-02 15:07 ` Stefan Monnier
  0 siblings, 1 reply; 34+ messages in thread
From: Jean-Christophe Helary @ 2018-12-02 10:53 UTC (permalink / raw)
  To: help-gnu-emacs

I spend most of the day investigating why creating a list with setq was not "working".

For ex:
(setq list0 '(1 2))
(setq list1 list0)

If you do

(setcar list0 0)

then for some reason (for which I could not find an explanation in the elisp reference) the car of list1 also changes, and vice-versa.

Which is totally unexpected since when you do:

(setq list0 0)

list1 does not become 0

I don't suppose that's a bug, but really it ought the be very clearly documented in the reference. Also, I'd like to know why that's happening.

So, to avoid that behavior, I had to resort to using copy-tree:

(setq list1 (copy-tree list0))

Which is really not the first thing I would have thought about.

There are probably better ways to create lists based on other lists without "linking" the two, so I'd like some information about that.

Thanks in advance.



Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune





^ permalink raw reply	[flat|nested] 34+ messages in thread
[parent not found: <mailman.5010.1543748027.1284.help-gnu-emacs@gnu.org>]
[parent not found: <mailman.5042.1543777897.1284.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2018-12-05 16:59 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-02 10:53 using setq to create lists based on other lists Jean-Christophe Helary
2018-12-02 15:07 ` Stefan Monnier
2018-12-02 15:41   ` Jean-Christophe Helary
2018-12-02 16:05     ` Stefan Monnier
2018-12-02 16:23       ` Jean-Christophe Helary
2018-12-02 17:02         ` Stefan Monnier
2018-12-02 17:21           ` Jean-Christophe Helary
2018-12-02 19:11             ` Robert Thorpe
2018-12-02 23:44               ` Jean-Christophe Helary
     [not found]   ` <mailman.5028.1543765273.1284.help-gnu-emacs@gnu.org>
2018-12-03 13:43     ` Rusi
     [not found] <mailman.5010.1543748027.1284.help-gnu-emacs@gnu.org>
2018-12-02 11:21 ` Barry Margolin
2018-12-02 11:51   ` Stephen Berman
2018-12-02 12:22     ` Jean-Christophe Helary
2018-12-02 13:08       ` Stephen Berman
2018-12-02 13:28         ` Jean-Christophe Helary
2018-12-02 14:40           ` Michael Heerdegen
2018-12-02 15:34             ` Jean-Christophe Helary
2018-12-02 15:44               ` Michael Heerdegen
2018-12-02 15:57                 ` Jean-Christophe Helary
2018-12-02 15:00           ` Stephen Berman
2018-12-02 15:30             ` Jean-Christophe Helary
     [not found]             ` <mailman.5026.1543764670.1284.help-gnu-emacs@gnu.org>
2018-12-04  9:00               ` Barry Margolin
2018-12-02 12:03   ` Jean-Christophe Helary
     [not found] <mailman.5042.1543777897.1284.help-gnu-emacs@gnu.org>
2018-12-04  9:04 ` Barry Margolin
     [not found]   ` <(message>
     [not found]     ` <from>
     [not found]       ` <Barry>
     [not found]         ` <Margolin>
     [not found]           ` <on>
     [not found]             ` <Tue>
     [not found]               ` <04>
     [not found]                 ` <Dec>
     [not found]                   ` <2018>
     [not found]                     ` <04:04:52>
2018-12-04 13:56   ` Stefan Monnier
2018-12-05  1:07   ` Robert Thorpe
2018-12-05  2:32     ` Drew Adams
2018-12-05  6:45       ` Jean-Christophe Helary
2018-12-05  8:00         ` Marcin Borkowski
2018-12-05  8:11           ` Jean-Christophe Helary
2018-12-05 14:57         ` Drew Adams
     [not found]         ` <mailman.5218.1544021892.1284.help-gnu-emacs@gnu.org>
2018-12-05 16:59           ` Barry Margolin
     [not found]     ` <mailman.5186.1543978155.1284.help-gnu-emacs@gnu.org>
2018-12-05 16:50       ` Barry Margolin
     [not found]   ` <mailman.5145.1543931778.1284.help-gnu-emacs@gnu.org>
2018-12-05 16:47     ` Barry Margolin

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).