When writing macros it is good practice to separate what you think should happen at compile time from what you think should happen at run time. If
Context(m) takes a symbol or expression as an argument, then what you have would suffice. More likely you want
Context(m) to evaluate at run time, it should appear within the
quote block as if it were normal code (which it is).
I also find it much easier to just escape the entire expression if you need to escape anything at all. (I find the code hygiene transformations unbelievably confusing.) You can always create obfuscated symbols using
So, for example, you might want something like:
for i ∈ 1:Context($m)
If you want both compiler information (i.e. such as variable names) and run-time information, you should either add arguments or methods to
Context, or create multiple different functions. For example
somesym = Expr(:quote, s) # some other symbol coming from the macro input somewhere, here a quote
for i ∈ 1:Context($m, $somesym)
but it’s hard for me to give better advice without knowing more about your use case.