Reputation: 1093
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?
Upvotes: 3
Views: 557
Reputation: 7893
You could also do:
julia> @eval const $(Symbol("@print")) = $(Symbol("@show"))
@show (macro with 1 method)
julia> @print 1 + 1
1 + 1 = 2
2
Upvotes: 5
Reputation: 1742
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
.
Upvotes: 6