Skip to Main Content
Mastering Elixir
book

Mastering Elixir

by André Albuquerque, Daniel Caixinha
July 2018
Intermediate to advanced content levelIntermediate to advanced
574 pages
14h 7m
English
Packt Publishing
Content preview from Mastering Elixir

Hygienic accesses

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.

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781788472678Supplemental Content