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

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

Re: Macro Expansion Inconsistency


From: Stefan Monnier
Subject: Re: Macro Expansion Inconsistency
Date: Tue, 16 Dec 2014 18:30:57 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> (defmacro test (name)
>   `(let* ((name             ',name)
>           (symbol           (intern (concat "some" "-" (symbol-name name)))))
>      ,symbol))

You have 2 macros here: the one you define (test) and the one you use
(backquote).  The problem is in the one you *use*.
I.e. you can reproduce your problem by running the following:

   `(let* ((name             ',"hello")
           (symbol           (intern (concat "some" "-" (symbol-name 
"hello")))))
      ,symbol))

I.e. the `symbol' variable should be bound in `let' that is executed
during the macro expansion whereas you instead return a form that binds
it (so this `let' binding of `symbol' would only happen later when the
expanded code is executed, which here doesn't happen since you first
try to get the value of `symbol' which signal an error since there is
no such variable at that time).


        Stefan




reply via email to

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