4 ms·
>The problem for me is that I've learned to avoid macros in other languages. Macros in other languages are significntly unlike Lisp macros. You should take a l
by flavio81 9y ago
>The problem for me is that I've learned to avoid macros in other languages.
Macros in other languages are significntly unlike Lisp macros. You should take a look at the Practical Common Lisp book (available for free online) to have an idea on how you can easily leverage Lisp macros for more readable, succint, easy to understand code.
>But if you introduce macros, or code writing code, then you have a much more complex mental model
In Lisp, you use the different tools available (macros, CLOS, readtables, etc) to achieve a simpler translation between the problem domain and your actual source code.
If you are using them to create more convoluted, harder-to-understand code, then "you're doing it wrong", just as you can, for example, write rather clean C code versus code that would win the IOCCC (International Obfuscated C Code Competition).
- qohen 9y agoAnother free Lisp book, one that focuses on macros -- and is quite readable -- is YC-founder Paul Graham's "On Lisp". There's a download page [0] (for the book and code) at paulgraham.com as well as the following on a description page [1]: On Lisp is a comprehensive study of advanced Lisp techniques, with bottom-up programming as the unifying theme. It gives the first complete description of macros and macro applications. The book also covers important subjects related to bottom-up programming, including functional programming, rapid prototyping, interactive development, and embedded languages. The final chapter takes a deeper look at object-oriented programming than previous Lisp books, showing the step-by-step construction of a working model of the Common Lisp Object System (CLOS). As well as an indispensable reference, On Lisp is a source of software. Its examples form a library of functions and macros that readers will be able to use in their own Lisp programs. [0] http://www.paulgraham.com/onlisptext.html http://www.paulgraham.com/onlisptext.html [1] http://www.paulgraham.com/onlisp.html http://www.paulgraham.com/onlisp.html