I found one previous conversation related to this, but unfortunately the 
answer didn't work for me. Hopefully I'm not asking an obvious question.

Suppose I have some macro:
macro mytest(fn::Symbol, ex::Expr)
  quote
    $(esc(fn))($ex)
  end
end

and I have some function that takes in the expression to operate on it:
myfun(ex::Expr) = ...

the problem (which may be obvious) is that `$ex` gets evaluated with the 
macro, and I won't pass an `Expr` to `myfun`. A quick demonstration:

foo(x, y) = x+y
println(expandmacro(:(@mytest foo 1+2)))

gives:
begin  # .../mtestmod.jl, line 38:
    foo(mtestmod.+(1,2))
end

What I can't figure out is how to keep `ex` an expression that is passed to 
foo (at least without writing out Expr by hand). I've tried many 
combinations of syntax to try to preserve the Expr-ness of `ex`.

Thanks!

Reply via email to