Metaprogramming first steps

This is about macro hygiene. e.g. here is a simple example:

julia> macro foo(ex)
           ex
       end
@foo (macro with 1 method)

julia> @macroexpand @foo x = 1
:(var"#64#x" = 1)

julia> macro foo(ex)
           esc(ex)
       end
@foo (macro with 1 method)

julia> @macroexpand @foo x = 1
:(x = 1)

Here is the relevant docs section on Hygiene: Metaprogramming · The Julia Language

2 Likes