Alias for a macro


How can I alias a macro?
I would like to use @dot instead of @..


You could do

macro dot(expr)
    :(@. $expr))

There is also the predefined alias @__dot__.




@. seems to be more elaborate than the above definition of @dot.
It also works for in-place assignments for which @dot gives an error:

x = [0,1,2]
y = zeros(3)
@dot y = exp(x)


You need to use esc correctly.

macro dot(expr)
    esc(:(@. $expr))
  1. Is this correct?
  2. Is this the simplest way to alias a macro?


No. On 0.6 the correct and preferred way is :(@. $(esc(expr))), i.e. you must escape each input once and exactly once. On master this is broken so the only way you can do this is esc(:($Base.@. $(esc(expr))))

You can also just do @eval const $(Symbol("@dot") = $(Symbol("@__dot__")))


Thank you very much for the detailed explanation.

There was a small typo in parenthesizing, but the last version also works:
@eval const $(Symbol("@dot")) = $(Symbol("@__dot__"))