Hi all,
I'd like to be able to load in a module, then macroexpand the whole thing,
then print out the macroexpanded version.
This should be a full, recursive macroexpand.
I've noticed there is a function called macroexpand that normally does what
i want:
> macro m(x) 1 end
..
> @m(2)
1
> macroexpand(:(1 + @m(2)))
:(1 + 1)
so that is fine and dandy, but inside a module this doesn't seem to work:
> macroexpand(:(
module M
macro m(x) 1 end
x = 1 + @m(2)
end
))
:(module M
eval(x) = begin # none, line 2:
top(Core).eval(M,x)
end
eval(m,x) = begin # none, line 2:
top(Core).eval(m,x)
end # none, line 3:
$(Expr(:macro, :(m(x)), quote # none, line 3:
1
end)) # none, line 4:
x = 1 + @m(2)
end)
As you can see in the second to last line, @m(2) is not expanded, and I'm
confused as to why that is.
Ideally, this macroexpanding of a module would allow me to also resolve
imports and includes properly, so I could just slurp up a file and dump out
the macroexpanded version.
Thank you!
Vishesh