3 ms·
If you're just writing new functions and data structures, then you're not trying to write a DSL, but avoiding doing so. Why the functions and structures might
by kazinator 6y ago
If you're just writing new functions and data structures, then you're not trying to write a DSL, but avoiding doing so.
Why the functions and structures might not be enough is that there may be situations where their direct use is too difficult or error-prone somehow.
It can make sense to start with the new functions and structures first and then see if some usage pattern calls out "I want to be a new macro".
- AnimalMuppet 6y agoHmm. That fits with advice from Extreme Programming: "Pay attention to pain". When it's hard (or even tedious) to write something, pay attention to that. It's trying to tell you something.
- TeMPOraL 6y agoThat's usually the advice given to aspiring macro writers. You write ordinary code, but when you start feeling there's a higher-level concept there for which you repeatedly write the same boilerplate, that's when you consider using macro to introduce said concept as a first-class, explicit thing. It's not that different than abstracting through functions or objects, but it allows you to abstract away the repetitive code structure as well.