I’ve been working on a macro which uses $
in a special way. But for certain tests, I need to use @eval
or eval
. Here is a very stupid MWE showin the problem, roughly
julia> macro with_dollar(x)
if x isa Expr && x.head == :$
esc(:(y = 100))
else
esc(:(y = 200))
end
end;
julia> @with_dollar $a
100
julia> @eval (@with_dollar $a)
ERROR: UndefVarError: a not defined
Is there a way to tell @eval
to ignore it’s own rules about $
? How do other packages handle this?