emacs-devel
[Top][All Lists]
Advanced

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

Re: Using the content of a dynamic variable in a macro


From: Lynn Winebarger
Subject: Re: Using the content of a dynamic variable in a macro
Date: Sat, 25 Feb 2023 07:32:00 -0500

On Sat, Feb 25, 2023, 5:19 AM Damien Cassou <damien@cassou.me> wrote:
Eli Zaretskii <eliz@gnu.org> writes:
>> Why isn't the compiler aware of the foo-var variable?
>
> Because lexical-binding is turned on?

yes it is but I miss the deep understanding to fully understand.

Lexical binding isn't the issue - the variable is global in scope.
The issue is that when you explicitly run the byte-compiler in batch mode, the "defvar" _expression_ is only compiled, not evaluated, while the defmacro is evaluated, and the application of the macro function is evaluated during compilation.
Hence you need "eval-when-compile" per Tomas's response.
The reason it works in interactive mode is that the defvar is evaluated, not compiled, and the macro function is evaluated in the run-time environment.

Lynn


reply via email to

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