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

The real use cases for macros boil down to 3 main areas:

1. Changing order of evaluation.

2. Creating new binding forms.

3. Implementing a data sub-language a.k.a. DSL

Although arguably #3 doesn't require macros, arguably it requires macros to do elegantly (Rubyists might argue not) and reliably (instead of monkey-patching, using hygiene and a macro-aware module system that can handle towers/layers of such systems).




Well, 1 and 2 are the only cases where they are absolutely required, but I've seen other use cases. For example, the ClojureScript templating library Dommy uses macros to optimize selector code at compile time, which gives some impressive speedups (IIRC Prismatic found it to be twice the speed of jQuery).




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: