bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#43601: 27.1; Macroexpansion bug in `push'


From: Phil Sainty
Subject: bug#43601: 27.1; Macroexpansion bug in `push'
Date: Fri, 25 Sep 2020 17:56:09 +1200
User-agent: Orcon Webmail

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







reply via email to

[Prev in Thread] Current Thread [Next in Thread]