3 ms·
Macros can be useful as syntax sugar, but a lot of the time they obscure the meaning of the code. In general, data is better than functions, and functions are b
by weavejester 12y ago
Macros can be useful as syntax sugar, but a lot of the time they obscure the meaning of the code. In general, data is better than functions, and functions are better than macros.
For instance, in your parser example, you could get exactly the same syntax just using higher-level functions. There's no need for a "defparser" macro at all.
Clojure treats macros as a last resort, something to reach for only when you've exhausted all other options. Without them, we wouldn't be able to have language extensions like core.async, core.typed, and core.logic packaged up as optional libraries, but in most cases they should be used sparingly.