[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using the content of a dynamic variable in a macro
From: |
Eli Zaretskii |
Subject: |
Re: Using the content of a dynamic variable in a macro |
Date: |
Sat, 25 Feb 2023 11:38:01 +0200 |
> From: Damien Cassou <damien@cassou.me>
> Date: Sat, 25 Feb 2023 09:34:07 +0100
>
> I'm wondering why the code below works but won't compile.
>
> foo.el:
> (defvar foo-var '((message "hello world")))
>
> (defmacro foo-macro ()
> `(progn
> ,@foo-var))
>
> (defun foo-fun ()
> (foo-macro))
>
>
> $ emacs --batch -l foo.el --eval '(foo-fun)'
> hello world
>
> $ emacs --batch --eval '(find-file "foo.el")' --eval
> '(emacs-lisp-byte-compile)'
> In toplevel form:
> foo.el:32:1: Error: Symbol’s value as variable is void: foo-var
>
> Why isn't the compiler aware of the foo-var variable?
Because lexical-binding is turned on?
Re: Using the content of a dynamic variable in a macro, tomas, 2023/02/25
Re: Using the content of a dynamic variable in a macro, Basil Contovounesios, 2023/02/27