It is not uncommon that most of the expression returned by a macro needs to be escaped.
using MacroTools const IGNORE = [true] macro foo(f) fdict = MacroTools.splitdef(f) fdict[:body] = quote if IGNORE return nothing end $(fdict[:body]) end return $(esc(MacroTools.combinedef(dict))) end
Here, I inserted a hook such that the function will not be executed if
IGNORE is true.
IGNORE is set to a vector such that I can change the
false at runtime.
Clearly, the const
IGNORE should be resolved in the macro environment. However, it would be rather tedious to manually escape everything else except for
Is there a way to somehow label the constant
IGNORE such that it will not be escaped even it’s inside the