Summary
We accomplished a lot throughout this chapter. Let's look back at the main topics that we covered:
- The Elixir abstract syntax tree consists of a tree-like data structure composed of nested three-element tuples representing your code. This data structure can be manipulated using the
quote/2andunquote/1constructs and is also called a quoted expression. - By default, Elixir enforces a macro hygiene rule that doesn't allow us to impinge into the caller module, unless we specifically want to.
- Macros are functions whose arguments are quoted before reaching the function body and have to return valid quoted expressions as well. Macros are expanded right before compile time.
- The
useand__using__/1macros let the macro module inject code into the caller module. We used these constructs to register a@time_unitmodule attribute in the caller module, so we could control the time units used by thedefchrono/2macro. - We created a domain-specific language to streamline the definition of parallel GenStage...