4 ms·
As a hobbyist that keeps trying to break into lisp, I think the absence of an obviously good formatter for lisps has made things much harder. This looks like h
by n8henrie 2y ago
As a hobbyist that keeps trying to break into lisp, I think the absence of an obviously good formatter for lisps has made things much harder.
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.
- skydhash 2y agoThe way to have a good time with lisp is using Emacs and Slime/Sly. And if you like shortcuts, you can try Paredit for structural editing. 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.
- JBiserkov 2y agoYou can also try "rainbow parens" color scheme that makes nesting much easier to see.
- kazinator 2y agoYou are looking at the wrong thing. Nobody looks at bunched parentheses for any reason, unless they are investigating a suspicion that the code's indentation is wrong. In that situation, all that matters is whether the bunch contains the correct number of parentheses, not which specific closers match which specific openers. (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.
- n8henrie 2y ago> One simple thing you can do is just automatically reindent the whole block. This is exactly the point of my comment -- the absence of an obvious / reasonable automatic formatter is the problem I'm pointing to.
- kazinator 2y agoIn Vim, use V to go into line-oriented visual selection mode. Move the cursor over the range of lines to be reindented and hit =.