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/2
andunquote/1
constructs 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
use
and__using__/1
macros let the macro module inject code into the caller module. We used these constructs to register a@time_unit
module attribute in the caller module, so we could control the time units used by thedefchrono/2
macro. - We created a domain-specific language to streamline the definition of parallel GenStage...