An open API service indexing awesome lists of open source software.

https://github.com/curiosum-dev/elixir-macros-metaprogramming

A companion repository to our article at Curiosum: https://curiosum.dev/blog/elixir-trickery-using-macros-metaprogramming?utm_source=github&utm_medium=social
https://github.com/curiosum-dev/elixir-macros-metaprogramming

Last synced: 4 months ago
JSON representation

A companion repository to our article at Curiosum: https://curiosum.dev/blog/elixir-trickery-using-macros-metaprogramming?utm_source=github&utm_medium=social

Awesome Lists containing this project

README

          

This is a companion repository for the ["Elixir Trickery: Using Macros and Metaprogramming Without Superpowers"](https://curiosum.dev/blog/elixir-trickery-using-macros-metaprogramming?utm_source=github&utm_medium=social) article published at [curiosum.dev](https://curiosum.dev).

## Outline

1. The axioms to keep in mind: The truth about the nature of code, macros and functions in Elixir that you need to realize before reasoning about metaprogramming.
2. Metaprogramming at its core: code that generates code: The core difference between how Elixir understands metaprogramming and how it works in many popular languages.
3. AST: Tree representation of code: The internal representation of code in Elixir and how it can be manipulated and accessed.
4. Macros as functions manipulating ASTs: On the nature of Elixir macros which are little more than a tool to transform abstract syntax trees, with some syntactic sugar to make it feel more natural.
5. The way to understand `quote` and `unquote`: Explaining how quoting and unquoting to code is like interpolation to strings.
6. Wrapping up: Which approach to use when creating macros?: Why and when to use either macro creation strategy described in the article.