3 ms·
Please take a look at Lisp macros. I finally got it at some point. It is a way of generating code on the fly. After I understood under what circumstances macros
by sn41 6y ago
Please take a look at Lisp macros. I finally got it at some point. It is a way of generating code on the fly. After I understood under what circumstances macros can abbreviate code, every other language will look unnecessarily verbose.
This is enabled by the fact that code in Lisp is also written in the form of lists. Code is data, data becomes code if you write a macro to process the data.
For example, is the following data or code?
(book
(author "Jonathan swift")
(title "A Modest Proposal"))
It definitely looks like data. But it can be made into code using an appropriate macro.
What probably Lisp trails in is type inference and bleeding edge libraries.
- phoe-krk 6y ago> What probably Lisp trails in is type inference SBCL type inference is actually getting better and better over time, giving you pretty effective gradual typing. Additionally, a Common Lisp implementation called SICL is in the works, with an advanced compiler and type inference engine. https://github.com/robert-strandh/SICL/ https://github.com/robert-strandh/SICL/
- cat199 6y ago> It definitely looks like data. But it can be made into code using an appropriate macro. to chime in, it also can be made into 2 systems - one which defines 'book' as an in-memory object which can be inspected, and one which, say, defines a remote database object - your 'language spec' is the syntax, and you can implement multiple implementations, or replace subsystems as you build up the bigger thing - e.g. 'now my hashtables are persisted to disk', etc