| ▲ | dreamcompiler 5 hours ago | ||||||||||||||||||||||
That's true but it's not the most important aspect of macros. Macros let you define a new language that describes your problem solution more directly than you can in raw Lisp. In other words they let you create a Domain-Specific Lamguage (DSL). You can create DSLs in other languages too but it's so difficult that it's uncommon. In Lisp it's so easy that DSLs are a primary programming technique. | |||||||||||||||||||||||
| ▲ | klibertp 4 hours ago | parent | next [-] | ||||||||||||||||||||||
I don't think that moving the evaluation to compile time is something you can just ignore when discussing macros. It's an important differentiator between macros and Fexprs[1]. IME, the primary use case for macros in Lisps is language extension, a step before a DSL. For every `loop` there are thousands of `with-x` macro implementations. See the macro-writing macros in Alexandria/Serapeum for the most common patterns. Also, some dynamic languages (Io, Prolog, Groovy) support DSLs through non-macro mechanisms. DSLs in those languages are as easy (or easier) to implement as in Lisps; however, they tend to be less performant. So, again, compile-time macro execution does matter for the DSL use case, too. | |||||||||||||||||||||||
| |||||||||||||||||||||||
| ▲ | throw-qqqqq 2 hours ago | parent | prev [-] | ||||||||||||||||||||||
I don’t disagree, but I think this is a matter of taste: i.e. which aspect you’d consider more important. You can create DSLs without macros, for example by parsing and interpreting at runtime, but macros let you move much of that logic to compile time. For me, that's the killer feature: writing code that looks dynamic or interpreted, but ends up as compiled code. | |||||||||||||||||||||||