4 ms·
Ask HN: How can you explain Lisp-style macros to non-Lispers
When I tell people that my favorite language is Clojure (pick your favorite LISP dialect), I inevitably have to explain what makes it so great. That brings me to macros, yet I struggle to explain what a macro is and what it can do succinctly. Any ideas on how to explain this to people from a mostly C/C++ background?
- kazinator 8y agoMacros are code that your program adds to the compiler to create custom language features just for that program (or as a library for other programs). A macro allows the compiler to recognize new syntax, and provides the translation of that syntax into working code.