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

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

Using the content of a dynamic variable in a macro


From: Damien Cassou
Subject: Using the content of a dynamic variable in a macro
Date: Fri, 24 Feb 2023 07:31:35 +0100

Hi,

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?

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill



reply via email to

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