4 ms·
> Every list of best practices, for every LISP, agrees that macro use is generally a "use rarely" thing. Not really. This best practice is for beginners and mi
by lispm 12y ago
> Every list of best practices, for every LISP, agrees that macro use is generally a "use rarely" thing.
Not really. This best practice is for beginners and mid-level programmers. They either write macros for the wrong purpose or in problematic ways. Thus they should avoid macros. Still they need to use macros, since languages like Common Lisp provide a lot of functionality through macros.
To get past that stage a book like 'On Lisp' by Paul Graham helps.
Many, but not all, advanced programmers will use and write a lot of macros.
- nickik 12y agoThats just not true in clojure. Good librarys in clojure have a data interface, function to produce that data and maybe a thin macro layer to make it a little more easy to use. While 'On Lisp' is a cool book, I rarly find the really advanced macro stuff usful. Once in awhile, you want to have something like a really good pattern matching compiler, and then your macros come in handy. But day to day, you dont need them much.
- lispm 12y agoLet's look at some Common Lisp example: https://github.com/Wukix/LambdaLite/blob/master/lambdalite.lisp https://github.com/Wukix/LambdaLite/blob/master/lambdalite.l... This is a recent tiny in-core database. The code is using LOTS of macros. It also implements a few non-trivial macros. Half of the code is implemented as macros. Code like that is not unusual in Lisp.
- deleted 12y ago[deleted]
- lostcolony 12y agoSure, if your code is only going to be touched by LISP experts, and/or has a sufficiently strong separation from that being touched by the novices/intermediates (i.e., like a library), macro away. There's a reason I qualified it with "generally" and "rarely".