[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27910: 24.5; local-scope; construct list
From: |
Andreas Schwab |
Subject: |
bug#27910: 24.5; local-scope; construct list |
Date: |
Tue, 01 Aug 2017 17:46:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
On Aug 01 2017, hw <huwei9527@gmail.com> wrote:
> Look at this code:
>
> (defun test ()
> "Test"
> (setq a '(A))
> (push 'B a)
> (nreverse a))
>
> (message "%s" (test))
> (message "%s" (test))
>
> The result of the code run on my emacs is:
>
> (A B)
> (B A B)
>
> Since 'a' is a local variable, it is expected to be lke this:
This is irrelevant, nreverse is destructively modifying the literal in
the function:
ELISP> (symbol-function 'test)
(lambda nil "Test"
(setq a
'(A B))
(push 'B a)
(nreverse a))
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."