11 ms·
After writing Clojure for a few years, there were several times where I ended up with a complex function with unbalanced parens, and the only way I could fix it
by lastofus 4y ago
After writing Clojure for a few years, there were several times where I ended up with a complex function with unbalanced parens, and the only way I could fix it was to basically re-write the function piece by piece. This is something I've never had to do in any other language.
I'd also end up in not great places when utilizing parinfer while editing code written using different formatting than what parinfer expected. I'd have to fall back to paredit and hope for the best.
This is all to say that yes, sometimes editing lisp syntax is "hard", at least for me. Turns out some humans make so-so AST parsers.
That said, structural editing is great once you get good at it, and something I miss back in other languages.
- soegaard 4y ago> After writing Clojure for a few years, there were several times where I ended up with a complex function with unbalanced parens, and the only way I could fix it was to basically re-write the function piece by piece. That's the punishment for removing some of the "reduntant" parentheses from Scheme. Compare Clojure: (let [a 1 b 2] (+ a b)) Scheme: (let ([a 1] [b 2]) (+ 1 2)) If for some reason, say, `b` get deleted a Scheme compiler can tell you which binding pair has a problem. In more complicated setups, in Scheme/Racket I indent the piece of code, and from the indentation I can see, where end parenthesis is missing.
- kazinator 4y agoWhat editor were you using? Maybe it had broken indentation? You should be able to indent the code automatically and then the wrong subordination of the pieces shows up as wrong indentation. Like, e.g. what you think should be inside some conditional statement isn't intended at the expected level for that role.
- outworlder 4y ago> After writing Clojure for a few years, there were several times where I ended up with a complex function with unbalanced parens, and the only way I could fix it was to basically re-write the function piece by piece. Mess up Python indentation and you get something like that, but worse.