help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hash strangeness


From: Marcin Borkowski
Subject: Re: hash strangeness
Date: Tue, 04 Nov 2014 08:39:40 +0100

On 2014-11-04, at 04:04, Drew Adams wrote:

>> > I expect '(a b c) to create a new list with these symbols
>> > every time it runs.
>> 
>> Why do you expect that?
>> '(a b c) is short for (quote (a b c)). quote returns its argument, it
>> doesn't make a copy of it.
>> 
>> I'm sure somewhere in the Elisp programming manual it mentions that you
>> shouldn't use destructive functions on literal lists, like the Common
>> Lisp spec does.
>
> Here is one place: the Elisp manual, node `Rearrangement`.  Search for
> "a common pitfall".
>
> https://www.gnu.org/software/emacs/manual/html_node/elisp/Rearrangement.html

And to see it yourself, execute (e.g. with C-x C-e) the following in
order:

(defun myfun () (setq myvar '(a b c)))
(myfun)
(symbol-value 'myvar)
(symbol-function 'myfun)
(nconc myvar '(1 2 3))
(symbol-value 'myvar)
(symbol-function 'myfun)

Hth,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University



reply via email to

[Prev in Thread] Current Thread [Next in Thread]