2 ms·
Braces can be formatted in a Lisp-inspired style! Try it like this: if (x) { if (y) { if (z) { foo; } } } The rules are a little different. We
by kazinator 2y ago
Braces can be formatted in a Lisp-inspired style!
Try it like this:
if (x)
{ if (y)
{ if (z)
{ foo; } } }
The rules are a little different. We have two-space indentation, like what is favored in Lisp, but there is a space after the opening brace. For symmetry, we put spaces between the closing ones. It works best if we don't "cuddle" the opening brace but put it on a new line.
There is a rhyme and reason to it, and consistency.
I've written some C programs that way, though not recently and can't point to any online examples.
However, I also wrote, and maintain, the Yacc grammar file in TXR Lisp in this style (just the actions in the grammar portion). For whatever reason, it works well in grammar files.
https://www.kylheku.com/cgit/txr/tree/parser.y https://www.kylheku.com/cgit/txr/tree/parser.y