Mathematical notation often gets brought up as an example of there being problems with Lisp syntax. I have problems with that. For one, how often do you actually write...
foo := 7 * 3 + 4 - 5;
Instead of:
foo := 20;
Which, in Lisp syntax could be as simple as:
(set! foo 20)
I could see an exception being made for something like:
constant MEMORY := 640 * 1024;
But the Lisp equivalent:
(defconstant! MEMORY
(* 640 1024))
Isn't _THAT_ much worse.
With more complex examples we still see that the difference isn't too terrible, especially as we try to make code more readable. An example of code whose readability is questionable could be:
r := (t - l) / (n - 1) * n;
Which, when we choose names with a little more meaning could become:
readjusted_score := (total_score - lowest_score) / (number_of_students - 1) * number_of_students;
Of course, that line is a bit long (just a bit, but I'm not interested in actually going and typing out a very long line), so it could be reformatted to something like:
readjusted_score := (total_score - lowest_score)
/ (number_of_students - 1)
* number_of_students;
Which isn't _TOO_ much different from:
(set! readjusted-score
(*
(/
(- total-score lowest-score)
(- number-of-students 1))
number-of-students))
And in fact, the Lisp syntax could make certain errors more visible, such as when we compare the following two snippets:
readjusted_score := (total_score - lowest_score)
/ (number_of_students + 1)
* number_of_students;
(set! readjusted-score
(*
(/
(- total-score lowest-score)
(+ number-of-students 1))
number-of-students))
And yes, indeed, when we start looking outside of mathematics, sometimes a little bit of sugar can even reduce the amount of brackets needed in Lisp syntax beyond the brackets needed in non-Lisp syntax:
abstractFactoryInstanceBean := AbstractFactory.getInstance().getBean().initialize();
(set! abstract-factory-instance-bean
(-> Abstract-Factory
get-instance
get-bean
initialize))
Speaking purely of mathematics, writing a function which turns infix syntax into Lisp syntax isn't too daunting anyway, it's even an exercise in good old SICP, so with very little effort we could write a macro to let us do the following:
(set! foo
(infix bar + baz * (quux - zot)))
Or, for the RPN aficionados:
(set! foo
(rpn bar baz quux zot - * +))
Of course this is very much personal opinion, but I would even go as far to say that infix notation isn't even that popular, as we can see with the following examples:
new_student := new Student("Name", points);
new_student := Student new ("Name", points);
if (length(students) > 30) {
error("Too many students in class!", length(students));
} else {
addStudent(new_student, class);
}
(length(students) > 30) if {
"Too many students in class!" error length(students);
} else {
new_student addStudent class;
}
All of that being said and done, I doubt I will change anyone's mind, but I personally really like Lisp syntax (as in good old, double open brackets on the let, Lisp syntax), and I just hope to see arguments which are a little stronger that the old classic 'we learn 1 + 2 in school, not (+ 1 2)'.