unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27910: 24.5; local-scope; construct list
@ 2017-08-01 12:02 hw
  2017-08-01 15:46 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: hw @ 2017-08-01 12:02 UTC (permalink / raw)
  To: 27910


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:

(A B)
(A B)

If I substitute '(setq a '(A))' with '(setq a (list 'A))', I get
the result I expect. I think there is no difference between
the two ways of constructing list(quote expression or list function),
but the result is different.If my understanding is right,
I doubt that the local binding or optimization of elisp cause this
problem.

Can anyone tell me the reason or tell me this is really a bug so
I will be careful with constructing list.

Thank you!









In GNU Emacs 24.5.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2016-04-17 on lgw01-04, modified by Debian
System Description:	Ubuntu 16.04.2 LTS

Configured using:
 `configure --build x86_64-linux-gnu --prefix=/usr
 --sharedstatedir=/var/lib --libexecdir=/usr/lib
 --localstatedir=/var/lib --infodir=/usr/share/info
 --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --build x86_64-linux-gnu --prefix=/usr --sharedstatedir=/var/lib
 --libexecdir=/usr/lib --localstatedir=/var/lib
 --infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes
 --enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.5/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.5/site-lisp:/usr/share/emacs/site-lisp
 --with-x=yes --with-x-toolkit=gtk3 --with-toolkit-scroll-bars
 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat
 -Werror=format-security -Wall' 'CPPFLAGS=-Wdate-time
 -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro''

Important settings:
  value of $LC_MONETARY: zh_CN.UTF-8
  value of $LC_NUMERIC: zh_CN.UTF-8
  value of $LC_TIME: zh_CN.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Messages

Minor modes in effect:
  global-linum-mode: t
  linum-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
(Y X A)
tt: (Y X A)
(A X Y)

(A B)
(4 3 2 1)

SBSBSB end
0.187039
Making completion list...

Load-path shadows:
/usr/share/emacs/24.5/site-lisp/debian-startup hides /usr/share/emacs/site-lisp/debian-startup
/usr/share/emacs24/site-lisp/latex-cjk-thai/thai-word hides /usr/share/emacs/24.5/lisp/language/thai-word

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
help-fns mail-prsvr mail-utils help-mode init config-auto-save
smart-auto-save pp auto-save-code auto-save-custom config-ui
config-theme solarized-theme solarized-definitions color-theme-custom
linum ui-custom config-miscellany file-lib file-custom miscellany-custom
config-elpa info easymenu package epg-config elpa-custom global-custom
path-lib file-code xterm time-date tooltip electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 183902 6810)
 (symbols 48 22987 0)
 (miscs 40 133 143)
 (strings 32 35066 12364)
 (string-bytes 1 870136)
 (vectors 16 12013)
 (vector-slots 8 397093 3882)
 (floats 8 70 746)
 (intervals 56 294 23)
 (buffers 960 12)
 (heap 1024 32681 704))





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#27910: 24.5; local-scope; construct list
  2017-08-01 12:02 bug#27910: 24.5; local-scope; construct list hw
@ 2017-08-01 15:46 ` Andreas Schwab
  2017-08-01 16:02   ` Noam Postavsky
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2017-08-01 15:46 UTC (permalink / raw)
  To: hw; +Cc: 27910-done

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





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#27910: 24.5; local-scope; construct list
  2017-08-01 15:46 ` Andreas Schwab
@ 2017-08-01 16:02   ` Noam Postavsky
  0 siblings, 0 replies; 3+ messages in thread
From: Noam Postavsky @ 2017-08-01 16:02 UTC (permalink / raw)
  To: 27910, Andreas Schwab, huwei9527

On Tue, Aug 1, 2017 at 11:46 AM, Andreas Schwab <schwab@suse.de> wrote:
>
> This is irrelevant, nreverse is destructively modifying the literal in
> the function:

See also `(elisp) Rearrangement'[1], and Bug#23417.

[1]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Rearrangement.html





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-01 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-01 12:02 bug#27910: 24.5; local-scope; construct list hw
2017-08-01 15:46 ` Andreas Schwab
2017-08-01 16:02   ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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