The macros we saw in the previous chapter transformed a syntax into another syntax at compile time. That is a neat tool since it allows many forms of compile-time operations while providing a clean and stable API. However, there are a great number of desirable compile-time things we cannot do just by text manipulations. Here are some:
- Extra code validation checks (lints).
- Compile-time validations: database schema checks, hostname validations.
- Generating code depending on the environment. For example, creating data models from live database tables, filling in data structures from the environment, optimizing runtime performance by computing expensive things at compile time, and so on.
Whereas macros-by-example from ...