In the official documentary, a macro example is provided:
macro time(ex) return quote local t0 = time() local val = $ex local t1 = time() println("elapsed time: ", t1-t0, " seconds") val end end
After this macro, a problem is immediately brought up:
module MyModule import Base.@time time() = ... # compute something @time time() end
In the above snippet,
ex in the macro definition will be resolved to the standard time function, not the one defined in the snippet.
This behavior seems to be quite strange to me. Naively, I would think since
ex is obtained from macro calling environment, how come it is resolved in macro defining environment? How is macro arguments resolve exactly?