4 ms·
Lisp always sounds cool to me until someone starts talking about macros. What's it like inheriting a lisp code base, finding out its full of homemade macros lik
by Yxven 7y ago
Lisp always sounds cool to me until someone starts talking about macros. What's it like inheriting a lisp code base, finding out its full of homemade macros like list comprehensions, and that they're not documented? Inheriting a code base is always scary, but I feel like it kicks it up a notch when your predecessors can customize the language itself. Are my fears justified?
- kazinator 7y ago> What's it like inheriting a lisp code base, finding out its full of homemade macros like list comprehensions, and that they're not documented? If such a macro is used in more than two places, it's generally a relief that the author did that instead of doing copy and paste by hand. The author had some coding idea, and formalized it into a little robot that writes that idea, which has a name. Even if that thing isn't accompanied by documentation, it can serve as a kind of documentation to what it's doing. Code is going to be full of homemade functions that are not documented; whether they are functions that write code at compile time, or whether they are run-time functions, is kind of a minor concern.
- bjoli 7y agoMacros look the same as functions in lisp, the only difference is that you can't pass them as function arguments. Unless there is a bug in the macro you just spend the same time understanding the macro that you would understanding a function. Most macros are just simple syntactic abstractions that expands simple code to more lines of relatively simple code to avoid boilerplate. Very rarely do people write complex beasts without documentation.