Re:Better Clojure formatting
by TeMPOraL on Friday December 07, 2018 @06:07AM
(#18626671)
Honestly, I think this is a bad idea. The way Lisp works, you need to load the code to have a shot at knowing the correct indentation. You can't just do it statically without abandoning the different syntax for function calls vs. block-of-code macros, as the distinction between the two may not be generally apparent until runtime.
[ Parent
| on HN ]
That isn't "how lisp works," that's how most people choose to format their lisp code.
And this is the entire point of the article. He discusses this at length: to reach the universality and speed of a `gofmt`-like formatting tool, we would have to give up on the idea that s-expressions should be indented differently based on their content.
Personally I find this a very tempting tradeoff. You may not, but indenting different s-exps in different ways based on their first element is not "correct," it's just... what most people choose to do.
> You may not, but indenting different s-exps in different ways based on their first element is not "correct," it's just... what most people choose to do.
They are not just s-expressions. They are programs. Just like a C code is not a random string, but a program.