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

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

Re: Macro Expansion Inconsistency


From: Joost Kremers
Subject: Re: Macro Expansion Inconsistency
Date: 16 Dec 2014 21:10:18 GMT
User-agent: slrn/pre1.0.0-18 (Linux)

Alexander Shukaev wrote:
> (defmacro test
>     (name)
>   `(let* ((name             ',name)
>           (symbol           (intern (concat "some" "-" (symbol-name name)))))
>      ,symbol))
>
> Running
>
> (test xxx)
>
> reports error: (void-variable symbol).
>
> What?
>
> Refactoring to
>
> (defmacro test
>     (name)
>   `(let* ((name             ',name))
>      ,(intern (concat "some" "-" (symbol-name name)))))
>
> and running
>
> (test xxx)
>
> works as expected.
>
> Could anybody clarify what's going on? Thanks.

Just consider when exactly the different parts of your macro are
evaluated. When is something that is quoted in the definition evaluated?
And when is something that is comma-escaped evaluated? Then look
carefully at what is quoted and what is comma-escaped. You'll see that
in the first version, something doesn't match.


-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


reply via email to

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