I can store a macro to a variable (let use the identity macro "id" as an 
example),

julia> idmacro = macro id(ex)
           :($(esc(ex)))
       end
@id (macro with 1 method)


How can I use this macro now? I can *almost* do it by hand by passing an 
expression as an argument and eval'ing the result, but it doesn't work 
because there's esc's left,

julia> @id 1+2
3


julia> idmacro(:(1+2))
:($(Expr(:escape, :(1 + 2))))


julia> eval(idmacro(:(1+2)))
ERROR: syntax: unhandled expr (escape (call + 1 2))
 in eval(::Module, ::Any) at ./boot.jl:234
 in eval(::Any) at ./boot.jl:233



Does Julia provide a way to use such macros stored in variables? Thanks!

Reply via email to