Interpolation in macro calls

I think what happens is that @btime just does something clever with the expression generated by interpolation syntax. Consider:

julia> macro m(e)
       @show e
       1
       end
@m (macro with 1 method)

julia> @m sin($x)
e = :(sin($(Expr(:$, :x))))
1

So @btime then presumably does some tricks to make the x not a slow global. Maybe such as doing a const xyz = x where xyz would be a gensym. But I’m just guessing.

I don’t see the connection here.

3 Likes