Conditionally defining a macro

Maybe just use isdefined:

julia> module M
           macro m() :() end
       end
Main.M

julia> isdefined(M, Symbol("@m"))
true

so:

if !isdefined(@__MODULE__, Symbol("@mymacro"))
    macro mymacro(ex)
        esc(ex)
    end
end
1 Like