GNU bug report logs - #27910
24.5; local-scope; construct list

Previous Next

Package: emacs;

Reported by: hw <huwei9527 <at> gmail.com>

Date: Tue, 1 Aug 2017 15:25:01 UTC

Severity: normal

Found in version 24.5

Done: Andreas Schwab <schwab <at> suse.de>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 27910-done <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> suse.de>
To: hw <huwei9527 <at> gmail.com>
Cc: 27910-done <at> debbugs.gnu.org
Subject: Re: bug#27910: 24.5; local-scope; construct list
Date: Tue, 01 Aug 2017 17:46:42 +0200
On Aug 01 2017, hw <huwei9527 <at> 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 <at> suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."




This bug report was last modified 7 years and 299 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.