Subject: Re: bug#27910: 24.5; local-scope; construct list
From: Andreas Schwab <[email-masked]>
To: hw <[email-masked]>
Cc: [email-masked]
Date: Tue, 01 Aug 2017 17:46:42 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

On Aug 01 2017, hw <[email-masked]> 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, [email-masked]
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."