Chapter 10: Working with Macros
In this chapter, we are going to explore the world of metaprogramming. Metaprogramming can be a great way to DRY up your code by consolidating boilerplate code into reusable chunks, or by processing data at compile time to generate additional code. First, we are going to take a look at the core piece of this feature: macros.
We will cover the following topics in this chapter:
- Defining macros
- Understanding the macro API
- Exploring macro hooks
By the end of this chapter, you will be able to understand when and how macros can be applied to reduce the amount of boilerplate code in an application.
Technical requirements
For this chapter, you will need a working installation of Crystal.
You can refer to Chapter 1
Get Crystal Programming 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.