[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trailing parens

Paul Graham wrote:
> Your reward for tuning out )))))))) is to be able to write
> macros.

Right. I agree. My point is that the parens have some usability
problems. These can cause real difficulty for new programmers and
programmers transitioning for other languages. The long-term upside
mitigates those problems. Lisp might be more popular today if people
sold the parens as a benefit as opposed to saying: "if you think that's
a problem you're just mistaken. It isn't a problem."

> In any case, if you write code in a functional style, you're
> going to end up with a collection of delimiters at the
> end of your code.  

Not in Python ;)

> I've found from experimenting with various syntactic tricks
> in Arc that it's actually a win if all the delimiters are
> parens.  It's a real nuisance to have expressions that end
> ))})]), because you can't tell if you've put the } in the
> right place.

A nuisance for the *writer* but for the *reader* and *maintainer* it is
all upside. When you change the code, you can expect a better error
message if you accidentally delete a paren.

Or you could use the Haskell/Python solution.

> What this suggests to me is that maybe one of the reason
> people don't write functional programs in languages with
> syntax is that the syntax gets in the way of it.  If so
> that's a second disadvantage of syntax (along with preventing
> macros).

IMO, human beings just prefer flatness to hierarchy and iteration to
recursion. I know that when I write Scheme (or really any language) I
often consciously flatten my code by defining local variables or
creating functions.

  (let* ((first (expression-to-calculate-first))
         (icap (expression-using-first)

I only defined "first" to flatten the structure and give the reader a
mental resting point.

A friend tells the story of a woman learning a text processing language.
The language was carefully designed to seem like you were just looking
for patterns in text and triggering rules on those patterns.  Although
patterns never directly invoke each other, the overall process is
recursive. One of his students accused him: "I'm a FORTRAN programmer
and I know recursion when I see it." Then she walked out.

 Paul Prescod