Hacker News new | past | comments | ask | show | jobs | submit login

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".




Hmm. 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.


That'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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: