Why can you not just give macros enough meta-data so the reader-formatter knows what kind of formatting the form desire? Provided your lisp have macros of course...
CIDER, which the author of this blogpost maintains, has support for such metadata, under the style/indent key. The hope, when it was created, was that more editors would adopt this, but after years it's not caught on.
I use it extensively and it's both easy to use and super flexible (for the rare cases when you do need that).
One problem with this is that formatting now becomes a multi-file thing. You have now have to figure out what names actually refer to, which depends on building a project model to correctly resolve imports, etc....
Compare this with traditional formatters, which you can run on each single file individually, this is much more complex and also harder to parallelise.
I am not sure if I understand what you mean with multi-file and why it matters. As a lisp, the program is already in memory, I can interact with it through the repl. I am sure I can ask it to format itself?
If the program has syntax errors, nothing can happen, how would it know how to format it self if it is not correct?
Perhaps the approach is very different in lisp (and smalltalk which I have some experience with), there is no parsing of the program from the outside - or - if you take that approach and treat the s-expr as dead text you have to sort of reimplement the parser (or the system) in order to have some understanding of it, which in my mind seems very inefficient.
Expez|5 years ago
I use it extensively and it's both easy to use and super flexible (for the rare cases when you do need that).
Here's a link to the indent spec, if you want to read more: https://docs.cider.mx/cider/indent_spec.html
bennofs|5 years ago
Compare this with traditional formatters, which you can run on each single file individually, this is much more complex and also harder to parallelise.
schpaencoder|5 years ago
If the program has syntax errors, nothing can happen, how would it know how to format it self if it is not correct?
Perhaps the approach is very different in lisp (and smalltalk which I have some experience with), there is no parsing of the program from the outside - or - if you take that approach and treat the s-expr as dead text you have to sort of reimplement the parser (or the system) in order to have some understanding of it, which in my mind seems very inefficient.