* bug#43601: 27.1; Macroexpansion bug in `push'
@ 2020-09-24 22:54 Sean Devlin
[not found] ` <handler.43601.B.160098811131831.ack@debbugs.gnu.org>
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Sean Devlin @ 2020-09-24 22:54 UTC (permalink / raw)
To: 43601
Hi folks,
I believe I've found a macroexpansion bug in the `push' macro. Open a
new instance of Emacs and evaluate the following form in the scratch
buffer:
(macroexpand '(push (list 'x)
(cdr my-list)))
The result (with some reformatting) is this:
(let* ((v (list 'x))
(v my-list))
(setcdr v
(cons v
(cdr v))))
Both values are bound to `v', so the former is shadowed by the latter.
Thanks!
In GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2020-08-12 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.2011
System Description: macOS 11.0
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
(x y)
See buffer *Pp Macroexpand Output*.
You can run the command ‘pp-macroexpand-last-sexp’ with M-x p-m-l RET
See buffer *Pp Macroexpand Output*.
Making completion list...
Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'
Configured features:
NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES
THREADS JSON PDUMPER
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date subr-x seq
byte-opt bytecomp byte-compile cconv mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-mode easymenu
cl-loaddefs cl-lib gv pp tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded 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 threads kqueue cocoa ns multi-tty make-network-process emacs)
Memory information:
((conses 16 46943 7509)
(symbols 48 6030 1)
(strings 32 15598 2351)
(string-bytes 1 514024)
(vectors 16 10404)
(vector-slots 8 132291 12524)
(floats 8 28 38)
(intervals 56 218 0)
(buffers 1000 13))
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#43601: Acknowledgement (27.1; Macroexpansion bug in `push')
[not found] ` <handler.43601.B.160098811131831.ack@debbugs.gnu.org>
@ 2020-09-24 23:17 ` Sean Devlin
0 siblings, 0 replies; 6+ messages in thread
From: Sean Devlin @ 2020-09-24 23:17 UTC (permalink / raw)
To: 43601
Hi folks,
Upon closer inspection, it looks like the two bindings are distinct. I guess the symbols must be created by `make-symbol’ or similar. Still, it might be nice for debugging if the symbols had distinct names.
Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#43601: 27.1; Macroexpansion bug in `push'
2020-09-24 22:54 bug#43601: 27.1; Macroexpansion bug in `push' Sean Devlin
[not found] ` <handler.43601.B.160098811131831.ack@debbugs.gnu.org>
@ 2020-09-25 5:56 ` Phil Sainty
2020-09-25 9:35 ` Philipp Stephani
2 siblings, 0 replies; 6+ messages in thread
From: Phil Sainty @ 2020-09-25 5:56 UTC (permalink / raw)
To: Sean Devlin; +Cc: 43601
On 2020-09-25 10:54, Sean Devlin wrote:
> Hi folks,
>
> I believe I've found a macroexpansion bug in the `push' macro. Open a
> new instance of Emacs and evaluate the following form in the scratch
> buffer:
>
> (macroexpand '(push (list 'x)
> (cdr my-list)))
>
> The result (with some reformatting) is this:
>
> (let* ((v (list 'x))
> (v my-list))
> (setcdr v
> (cons v
> (cdr v))))
>
> Both values are bound to `v', so the former is shadowed by the latter.
It's actually fine.
What you're seeing is the *printed representation* of the lisp objects,
and two completely independent symbols, each with the name "v".
(setq foo (macroexpand '(push (list 'x) (cdr my-list))))
=> (let* ((v (list 'x)) (v my-list)) (setcdr v (cons v (cdr v))))
(setq vfirst (caaadr foo))
=> v
(setq vsecond (car (cadadr foo)))
=> v
(eq vfirst vsecond)
=> nil
(cdaddr (caddr foo))
=> (v (cdr v))
(eq vfirst (car (cdaddr (caddr foo))))
=> t
(eq vsecond (cadadr (cdaddr (caddr foo))))
=> t
This is like:
(eq (make-symbol "v") (make-symbol "v"))
=> nil
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#43601: 27.1; Macroexpansion bug in `push'
2020-09-24 22:54 bug#43601: 27.1; Macroexpansion bug in `push' Sean Devlin
[not found] ` <handler.43601.B.160098811131831.ack@debbugs.gnu.org>
2020-09-25 5:56 ` bug#43601: 27.1; Macroexpansion bug in `push' Phil Sainty
@ 2020-09-25 9:35 ` Philipp Stephani
2020-09-25 9:40 ` Lars Ingebrigtsen
2 siblings, 1 reply; 6+ messages in thread
From: Philipp Stephani @ 2020-09-25 9:35 UTC (permalink / raw)
To: Sean Devlin; +Cc: 43601
Am Fr., 25. Sept. 2020 um 00:56 Uhr schrieb Sean Devlin <spd@toadstyle.org>:
>
> Hi folks,
>
> I believe I've found a macroexpansion bug in the `push' macro. Open a
> new instance of Emacs and evaluate the following form in the scratch
> buffer:
>
> (macroexpand '(push (list 'x)
> (cdr my-list)))
>
> The result (with some reformatting) is this:
>
> (let* ((v (list 'x))
> (v my-list))
> (setcdr v
> (cons v
> (cdr v))))
>
> Both values are bound to `v', so the former is shadowed by the latter.
These are different uninterned symbols:
(let ((print-gensym t) (print-circle t))
(print (macroexpand '(push (list 'x) (cdr my-list))))
nil)
⇒ (let* ((#2=#:v (list 'x)) (#1=#:v my-list)) (setcdr #1# (cons #2# (cdr #1#))))
In general, if you see a "weird" expansion like this, bind
print-gensym to non-nil to see the uninterned symbols.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#43601: 27.1; Macroexpansion bug in `push'
2020-09-25 9:35 ` Philipp Stephani
@ 2020-09-25 9:40 ` Lars Ingebrigtsen
2020-09-26 15:05 ` Lars Ingebrigtsen
0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-25 9:40 UTC (permalink / raw)
To: Philipp Stephani; +Cc: Sean Devlin, 43601
Philipp Stephani <p.stephani2@gmail.com> writes:
> In general, if you see a "weird" expansion like this, bind
> print-gensym to non-nil to see the uninterned symbols.
True. But we could change push to use a different name for the
gensymmed symbol to avoid confusions like this.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#43601: 27.1; Macroexpansion bug in `push'
2020-09-25 9:40 ` Lars Ingebrigtsen
@ 2020-09-26 15:05 ` Lars Ingebrigtsen
0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-26 15:05 UTC (permalink / raw)
To: Philipp Stephani; +Cc: Sean Devlin, 43601
Lars Ingebrigtsen <larsi@gnus.org> writes:
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
>> In general, if you see a "weird" expansion like this, bind
>> print-gensym to non-nil to see the uninterned symbols.
>
> True. But we could change push to use a different name for the
> gensymmed symbol to avoid confusions like this.
I've now done so in Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-09-26 15:05 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-24 22:54 bug#43601: 27.1; Macroexpansion bug in `push' Sean Devlin
[not found] ` <handler.43601.B.160098811131831.ack@debbugs.gnu.org>
2020-09-24 23:17 ` bug#43601: Acknowledgement (27.1; Macroexpansion bug in `push') Sean Devlin
2020-09-25 5:56 ` bug#43601: 27.1; Macroexpansion bug in `push' Phil Sainty
2020-09-25 9:35 ` Philipp Stephani
2020-09-25 9:40 ` Lars Ingebrigtsen
2020-09-26 15:05 ` Lars Ingebrigtsen
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).