4 ms·
I'm still wrapping my head around macros, but I have been able to come up with a couple use cases that I quickly realized were already covered by existing macro
by yetanotheruser 9y ago
I'm still wrapping my head around macros, but I have
been able to come up with a couple use cases that I quickly realized were already covered by existing macros, the most recent one being a less flexible -> macro.
Anyways, I kept reading places that lisp macros and c macros were completely distinct, which seems untrue after a couple years of trying clojure.
- flavio81 9y ago>Anyways, I kept reading places that lisp macros and c macros were completely distinct, which seems untrue after a couple years of trying clojure. I haven't used Clojure macros but as a programmer that uses both C and Common Lisp, I can say with good authority that C macros and CL macros are very different.
- yetanotheruser 9y agoYea, not the same. Similar motivations though, right?
- kbp 9y ago> I kept reading places that lisp macros and c macros were completely distinct, which seems untrue after a couple years of trying clojure. They're similar in that they're both compile-time functions that generate code, but they're very different in practice, because C macros are written in a text substitution language that knows virtually nothing about C, which naturally makes writing even simple macros very error-prone. Lisp macros, on the other hand, are written in plain old Lisp and receive regular Lisp data structures that you can use the whole language to operate on. A lot of people learn from C that macros are very difficult to get right, so it's important when they move to Lisp that they give them a second look, because Lisp is a much more capable language for code transformation than cpp.
- yetanotheruser 9y agoRight, that makes sense