'How to alias a macro in julia

I'd like to make a name alias of a macro. My current implementation is to create a new macro that call and pass over the argument, eg.:

macro print(xs...)
  quote
    @show $(xs...)
  end
end

Is there any better / built-in way to this?



Solution 1:[1]

In Julia 1.3, you can use the var"@macroname" syntax, like so:

var"@print" = var"@show"

Then, @show will be effectively aliased to @print.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anshul Singhvi