4 ms·
From a practical standpoint, basing everything off balanced parens (or square brackets, that makes no difference to me) makes the language much easier to write
by darkpuma 7y ago
From a practical standpoint, basing everything off balanced parens (or square brackets, that makes no difference to me) makes the language much easier to write in. Being able to jump to the matching paren makes it trivial to copy/paste blocks of code, delete code, replace code, etc. It's so much easier than with things like Python. For instance, from the first line of a block of racket, copying that block in vim (not an editor known for being well suited for lisp) is as simple as %y. How do you do that in Python? If you know you're after 5 lines you could do 5Y, but that requires you to count how many lines you're after. You could use visual selection mode with V and then highlight the relevant lines, but that is more keystrokes than %y. You can get extensions for vim that create concise movements for dealing with indented blocks of python code, but with lisp no such extension is necessary. Even in vi-compat mode or things like Busybox's vi implementation that has no extension support, % works.
What's it like for C? A little bit better than python, but worse than lisp. Consider this block of code:
if (foo) {
...
}
How can I yank that entire thing, if my cursor is on the first character of the first line? The obvious answer to me is v$%y, which is pretty convenient, it doesn't require counting, but it's also fragile. What if that opening squiggly brace was on a new line? Then I'd have to do something like vj%y
As far as I'm concerned, despite vim being considered a second rate editor at best for lisp, lisp is arguably still the language vim is best suited for, and that's entirely a consequence of the fundamental usefulness of s-expressions.