Sorry, I’m on a phone right now so I can’t run code, but try something like this:
function foo(T)
@doit(T)
end
The macro just gets the symbol T. It has no access to the value that T is bound to when you call foo
. After all, you haven’t even called foo
yet, so how could it?
The given example happens to work because it only involves global variables that were already defined at the time the macro was expanded. You can’t rely on that being the case.