Being a newbie to Lisp I'm wondering if the Lisp syntax could be "fixed"?
Some people say the syntax in Lisp is one of its biggest strengths. I don't quite understand this.
Isn't it possible to replace "obvious" parentheses with a combination of white spaces, new lines and indenting? Just like in Python?
It looks to me like parentheses are the most used characters in Lisp code. I'm wondering if that's true - but if it is, isn't this a suggestion, that there is some redundancy in the syntax?
Is there some simple answer to the question - why so many parentheses?
For example:
(defun factorial (x)
(if (= x 0)
1
(* x
(factorial (- x 1)))))
Why not:
defun factorial (x)
if (= x 0)
1
* x
factorial
- x 1
e.g. close parentheses at the end of line, and always open them on new lines. Only the 1 would be ambiguous - is it 1 or (1) - but we could introduce an exception - single tokens are not "listified".
Could this work?
Edit:
Thank you all! I see now there are some links at the lispin site.
My personal opinion on this is: don't use newlines and indentation as "implicit" separators (I also don't like implicit grouping by operator precedence, but that is a different, although related topic).
Example: Is this valid Python? Does it do what you expect?
I have a little proposal: we could use a preprocessor to indent Python code automatically, by putting special characters into the code that tell it where a statement begins and ends. How about parentheses for this?
You could take a look at Clojure. Lesser parentheses but more syntax to remember.
This thread is old, but I've decided to contribute, because I've created a very similar reader system.
EDIT: Some samples of usage:
For more information check the homepage of project.
To answer the question of why:
It's main use as far as i know is readability, so that people who look at your code can decipher it more easily.
Hope it helps.