Tinkering with macros

Despite all the meta hype, we can think about macros as normal functions that need to respect some constraints regarding their arguments and their output. Every argument passed to a macro is converted first into its quoted representation, and the value returned by a macro should also be a valid quoted representation. This is why you commonly see the last statement of a macro being a quote block. It's also worth recalling that macros, as functions, can only be defined inside a module.

Another aspect worth mentioning is that macros are expanded before compile time. Macro expansion is the name given to the compiler process of evaluating the macro code and then replacing the call to the macro by the outcome of evaluating ...

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.