Every time we are inside a quote block, Elixir is generating the quoted representation of that code block for us. If it finds an inexisting_var variable during this process, Elixir is happy to return its quoted representation, {:inexisting_var, [], Elixir}, on the quoted representation of the code block. However, if we inject this quoted expression on a caller module, we'll get an error because the inexisting_var doesn't exist at all on the context where the generated code will run.
Hygienic accesses
Even if the variable inexisting_var was defined in the caller context, the macro wouldn't be able to access it because we didn't use the var!/1 wrapper around the inexisting_var. If we try to compile the Playground module, we would get a warning ...
Get Mastering Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.