by n8henrie · 1y ago · 0 comments
This looks like how I've naively tried to format things, and having started with python kind of makes sense.
But trying to read / edit code with 5 parentheses bunched together, I have the hardest time telling if they are matched or where. Thank goodness for vim / helix auto-matching.
I just use the Tab key for indenting and it always work for me (there's a logic on where to break line to get correct indenting, and it makes it easy to see if you misplaced a parenthesis. Also, both Emacs and Vim, highlight the matched parenthesis, so I never wonder about if I have the correct number of closing parenthesis.
(foo
(bar
(baz (xyzzy arg))
(bar arg))
We know from the indentation that this is supposed to be a closed unit: (bar
(baz (xyzzy arg))
But it needs three closing parens ))) not just )).If this problem is not accidentally compensated by a ) in the wrong place elsewhere, this code will error out.
One simple thing you can do is just automatically reindent the whole block. The indentation will then match the incorrect parentheses and the problem will be clear. Undo the temporary reformatting and fix it.
This is exactly the point of my comment -- the absence of an obvious / reasonable automatic formatter is the problem I'm pointing to.