I have a macro that defines a module like so.
defmodule Bar do
def bar do
IO.puts \"I am #{inspect __MODULE__}\"
end
end
defmodule MacroFun do
defmac
I think that's because the place where you are unquoting (binding) the variable name
.
In the first case, you are unquoting the variable name
when creating a module, thus binding the variable at that moment would require to check for context (check if the code is inside another module, for example). So, you get your current atom plus the appropriate context: Runner.Foo
.
In the second case, you are unquoting the variable name
before it's placed in a context, therefore its value will not change and it'll be the atom Foo
(no context).