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

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

Re: Macro Expansion Inconsistency


From: Alexander Shukaev
Subject: Re: Macro Expansion Inconsistency
Date: Tue, 16 Dec 2014 23:58:32 +0100

>
>     (defmacro test (name)
>       `(let* ((name ',name)
>               (symbol (intern (concat "some" "-" (symbol-name name)))))
>          ,symbol))
>          ^^^^^^^
>
> The comma operator causes something to be evaluated when the macro is
> expanded, but the `symbol' binding doesn't exist until runtime (at which
> time it exists where the macro expanded, not within the macro's body).
>
> This is another version that will work (notice the lack of quoting):
>
>     (defmacro test (name)
>       (let ((symbol (intern (concat "some" "-" (symbol-name name)))))
>         symbol))
>

Yes, I get it, but then how do I do something like

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

but using variable `symbol'?


reply via email to

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