How it works...
In step 2 of this recipe, we define a macro that explicitly provides the different patterns that the engine can match to. Specifically, the alphanumeric characters are limited to ,, ;, and =>. While this allows Ruby-style map initialization, it also limits the elements that a DSL can have. However, macros are still great for creating a more expressive way to deal with situations. In step 6 and step 7, we show a way to create a web request handler using a more expressive way than the usual chained function calls. Step 4 and step 5 show the usage of the arrow (=>) inside macros and step 8 ties it all together by running the tests.
In this recipe, we created matching arms for the macro invocation to use, where the arms use a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access