I am coding some macros and in one of them I end up with a Dict{Symbol, Tuple{Symbol, Expr}}
, where the Expr
s are all supposed to be interpolated into the expression returned by the macro. What I am doing right now is this:
dict = Dict{Symbol, Tuple{Symbol, Expr}}()
# some code, filling up the dict...
quote
$(some_fn)(
$arg,
$arg2,
Dict{Symbol, Tuple{Symbol, DataType}}(
[p.first => (p.second[1], eval(p.second[2])) for p in $(dict)]
)
)
end
But this has the drawback of eval
working in the topmost scope, and I want this macro usable at module-level or from the REPL. Is there a way to interpolate all of those Exprs from the Dict’s values into a Dict constructor? Or am I doing this wrong and maybe there’s a better way of achieving this?