44 ms·
Now suppose three of you are working on the same project, and each brings their own code generator like this. You can take Common Lisp macros from multiple sou
by kazinator 2y ago
Now suppose three of you are working on the same project, and each brings their own code generator like this.
You can take Common Lisp macros from multiple sources and use them in the same expression, in any pattern of nesting.
- PaulHoule 2y agoIn principle. Most people find somebody else's metaprogramming-heavy Common Lisp difficult to work with. When you look at classic programs from the golden age of AI you find they either rewrote their Lisp prototype in C++ for speed or the Lisp program (like an expert system shell) is much smaller than you imagine possible but it looks like the engine of a UFO.
- aeonik 2y agoDo you have a link to one of these UFO engines that I can study up on?
- PaulHoule 2y agoSee https://www.cs.unm.edu/~luger/ai-final/code/LISP.ess.html https://www.cs.unm.edu/~luger/ai-final/code/LISP.ess.html and the more modern http://www.clara-rules.org/ http://www.clara-rules.org/
- deleted 2y ago[deleted]
- kazinator 2y agoThat code looks readable to me. It is well formatted and the functions are small, with simple control paths. No variable assignments or loops to unravel. It defines no macros, but refers to some defined elsewhere; the instructions say you are supposed to use a certain other source file related to Chapter 14 of a book. I could probably ramp up on this in a day, if I had reason to.
- kazinator 2y ago> Most people find somebody else's metaprogramming-heavy Common Lisp difficult to work with. Citation needed. Org names, projects, numbers. Also, how easy do people find someone's Java metaprogramming? Where the whole metaprogramming system is locally invented, not just its application to the problem?
- trealira 2y agoThough I've only seen other people's Lisp projects online and in books, I haven't seen metaprogramming that made it less readable - usually, it makes the program more readable. At most, it defines a DSL, e.g. COMFY 6502, which is a thin wrapper over 6502 assembly implemented as a DSL in Emacs Lisp. But most of the time, macros provide a readable interface over a bunch of hard-to-understand boilerplate generated code. [0]: https://dl.acm.org/doi/pdf/10.1145/270941.270947 https://dl.acm.org/doi/pdf/10.1145/270941.270947
- kazinator 2y agoRight. The reliable reference point for comparing the program with macros is the same program in which the macros have been expanded. Comparing it to some completely different, nonexistent program which solves the same problem without macros is fallacious.