I’m going through this macro tutorial by Sasa Juric: https://www.theerlangelist.com/article/macros_1
One thing that is confusing me however is that Macro.expand/2 doesn’t seem to do the same thing as the tutorial suggests.
This is the part.
iex(3)> quoted = quote do Tracer.trace(1+2) end
{{:., [], [{:__aliases__, [alias: false], [:Tracer]}, :trace]}, [],
[{:+, [context: Elixir, import: Kernel], [1, 2]}]}
iex(4)> expanded = Macro.expand(quoted, __ENV__)
{:__block__, [],
[{:=, [],
[{:result, [counter: 5], Tracer},
{:+, [context: Elixir, import: Kernel], [1, 2]}]},
{{:., [], [{:__aliases__, [alias: false, counter: 5], [:Tracer]}, :print]},
[], ["1 + 2", {:result, [counter: 5], Tracer}]},
{:result, [counter: 5], Tracer}]}
When I follow along and do Macro.expand(quoted, __ENV__)
it simply returns the quoted
AST completely unchanged, it doesn’t expand anything and I don’t understand why…