3 ms·
> That said: if the code is neither correctly indented or has the parens correctly balanced - then one is in a pickle. But you can format the code automaticall
by junke 10y ago
> That said: if the code is neither correctly indented or has the parens correctly balanced - then one is in a pickle.
But you can format the code automatically, and check if all is good by looking at the shape of your code (indentation). If the amount is the same but you put elements in a strange location, like:
(defun bar ()
(let ((a (foo)) (print (list a)))))
Simply pretty-printing it with PPRINT will do:
(DEFUN BAR ()
(LET ((A (FOO)) (PRINT (LIST A)))
))
(C-c RET, aka. slime-expand-1-inplace, will work too).
Indentation and parenthesis introduce a level of error checking by redundancy: the tools works on structured expressions, you look at indentation. Here above you can see that the body of the LET is empty, while there is a bogus binding in it.
The above example is in practice quite rare.
Most errors are easily spotted with paren highlighting. I use paredit, which makes structural editing easy (but which is not too rigid and allows me to make unstructured changes too). You generally don't have unbalanced parenthesis, and if you don't spot the bad syntax with indentation, the compiler has a chance to complain, too.