It takes a few days for the shortcuts (http://www.emacswiki.org/emacs/PareditCheatsheet) to become second nature, but then you never really thinkabout the parentheses again.
I'm not arguing Vim over Emacs here, I just wanted to point out that Vim has excellent support for parenthesized expressions.
Interestingly, when I write procedural code such as C or Perl, I put a single brace on each line. For example:
if (condition)
{
...
}
That makes it easier for me to move whole blocks around.However, when I write functional code such as Lisp or Fexl, I tend not to do that. For example:
# Collect any matching entries at the front of the list.
\collect = (\match\list list end \head\tail
match head (item head (collect match tail)) end)
I think that's because I tend to keep all my Fexl expressions very short, building them up step by step.Also, Fexl uses ";" as a "right-pivot" operator. For example:
\collect = (\match\list list end \head\tail
match head (item head; collect match tail) end)
So in many cases I can avoid multiple right parentheses. The Clojure example in the article would become: \myfn-a = (\a\b zero? b a;
recur (afn (bfn (...)) a) (dec b))1. Lisp has a lot more parens than C or Java has curly brackets. The cost to vertical space is exaggerated. Otherwise you end up closing in a new line sometimes and not others, which quickly becomes distracting.
2. Somebody once said (anybody have the quote?) that C and java code looks blocky, while lisp code looks more fluid, like clay being moulded. That aesthetic speaks to me.
(if (= x 0)
(foo x)
(bar x))
And: if (x == 0) {
foo(x);
}
else {
bar(x);
}
The Lisp code has 8 parenthesis, whilst the Java code only has 4 braces. However, the Java code also has 6 parenthesis and 2 semicolons, so in total the Lisp code only has 8 control flow tokens, whilst the equivalent Java has 12 (or 13, if you count the 'else').I am also a Scot - if that helps ;-)
This is from Paul Graham's book, On Lisp.