so that say:
foo 1 2 3
bar 1 2
if (eq qux 3)
fizzbuzz 7
is translated by the parser to: (foo 1 2 3)
(bar 1 2)
(if (eq qux 3)
(fizzbuzz 7))so that say:
foo 1 2 3
bar 1 2
if (eq qux 3)
fizzbuzz 7
is translated by the parser to: (foo 1 2 3)
(bar 1 2)
(if (eq qux 3)
(fizzbuzz 7))(setf new-links (append new-links (link-scanner (cu-body url-hash) (parse-uri cu-url url-hash)))))
That's a quick one-liner I wrote for part of a webcrawler. In Lisp you don't need to know anything much about parsing that syntax except that after an open parenthesis, you're going to have a function/macro followed by parameters.
Going by your example I could either do:
setf new-links (append new-links (link-scanner (cu-body url-hash) (parse-uri cu-url url-hash))))
or
setf new-links
append new-links
link-scanner
cu-body url-hash
parse-uri cu-url url-hash
or setf new-links append
new-links link-scanner
cu-body url-hash
parse-uri cu-url url-hash
In the first example I've hardly improved anything, just removed a single pair of parens.In the second example, I've split each new nested function call onto a new line and indented. This leaves "raw" parameters on the same line as the function call, whilst moving function params to the next line. (Note that Lisps don't make any distinction between the two usually).
In the third example, I've gone for some unholy mix where I've left the first nested function call on the same line as the first "raw" params, but moved the next params to the next line and repeated with any following functions. This is a mess...
Personally I think the 2nd example is actually quite readable. But here's the catch; this was 1 line from a 60 line function. If every line was multiplied by 5, is a 300 line function still as readable? And that's before you even get into any considerations of how to implement macros and other potentially complicated constructs.
EDIT: Admittedly, not every line is going to grow by a factor of 5, but it'll still be enough to turn a one page function into a multi-page function.
It's never really caught on though, I would guess due to inertia. Most Lisp programmers just get used the parens, and maybe those that can't end up not using Lisp.
Once I make a serious foray into Lispland maybe that'll change...
Emacs' automatic indentation to The Proper Place is tremendously useful. I find Lisp's indentation to be just as easy as Python's, for example -- likely as I have used a Lisp for six years before coming to Python.
Once you've used it for a while, you don't think of it as much different from using {} for control blocks, () for method calls, and [] for array indexing in other languages. For me, the parens "go away", in that I follow the program control flow more by indentation than by counting parens.
It would really open up the list world, especially to those of us comfortable with python.
It seems like such an obvious upgrade to me, since:
A: In no case will it break code that works now. B: It would always be possible to translate to and from it unambiguously, so if a team wanted to keep all of their code one way or the other, each individual developer could still see things with their own preference - imagine a tool like `gofmt`.
((foo 1 2) 3)
((bar 1) 2)
would be foo 1 2
3
bar 1
2May I propose:
(foo 1 2) 3
(bar 1) 2I think the main annoyance is not the syntax per se but the fact that calls are way more nested than in an imperative language counterpart.