On Fri, Jan 26, 2024 at 08:16:46PM +0000, Alan Mackenzie wrote: > Hello, Emacs. > > I have a problem in a macro, where I have the expression ,expr. I want > to evaluate it, but get the error message void-variable (expr). > > In the good old days, I could have tested this with > > (if (boundp 'expr) (eval ,expr)) > > , but now, with lexical variables, I can't find the equivalent to boundp. > Is there such a facility for lexical variables, and if so what is it? To offer something which might be half-right, but less whimsical than the typical Andreas's answers: lexical variables are only "known" at compile time (something to bear in mind when building your macro; I take you know that). But functions, like "boundp" take a symbol at run time and query it. The whole compile-time "world" is now somewhere under the Atlantic Ocean and only legends talk about it :-) One work-around would be "ignore-errors" (I take this is roughly what Common Lispers do). Assume lexical bindings, assume foo hasn't been defined: (ignore-errors foo) => nil (let ((foo 12)) (ignore-errors foo)) => 12 (Ignore-errors is a macro, so it gets expanded when useful to you) Perhaps there's a solution along these lines. Cheers, hth -- tomás