Why don't people like lisp?

Adam Warner usenet at consulting.net.nz
Sun Oct 19 19:46:34 EDT 2003


Hi Marcin 'Qrczak' Kowalczyk,

> What about reading (in books, on WWW)? I guess you would say
> "indentation"...
> 
> Indentation in Lisp is not clear enough. Let's look at an example from
> http://www-users.cs.umn.edu/~gini/aiprog/graham/onlisp.lisp:
> 
> (defun mostn (fn lst)
>   (if (null lst)
>       (values nil nil)
>       (let ((result (list (car lst)))
>             (max (funcall fn (car lst))))
>         (dolist (obj (cdr lst))
>           (let ((score (funcall fn obj)))
>             (cond ((> score max)
>                    (setq max    score
>                          result (list obj)))
>                   ((= score max)
>                    (push obj result)))))
>         (values (nreverse result) max))))
> 
> Note that only one pair of adjacent lines is indented by the same amount.
> Other alignments are in the middle of lines.

I have ignored the followup-to because your comment is ignorant. If you
want to make ignorant comments please only make them in comp.lang.lisp so
corrections don't also have to be posted to comp.lang.python.

Here is what a Common Lisp users see from the indentation:

1. IF takes a "test" form, a "then" form and in this case an "else"
form. By the indentation I can instantly see that the "test" form is
(null lst), the "then" form is (values nil nil) and the "else" form is:

      (let ((result (list (car lst)))
            (max (funcall fn (car lst))))
        (dolist (obj (cdr lst))
          (let ((score (funcall fn obj)))
            (cond ((> score max)
                   (setq max    score
                         result (list obj)))
                  ((= score max)
                   (push obj result)))))
        (values (nreverse result) max))))

2. LET is binding values to RESULT and MAX. By the indentation I can
instantly see that this binding is in effect for the remainder of the form:

        (dolist (obj (cdr lst))
          (let ((score (funcall fn obj)))
            (cond ((> score max)
                   (setq max    score
                         result (list obj)))
                  ((= score max)
                   (push obj result)))))
        (values (nreverse result) max))))

3. By the indentation I can also instantly see that the DOLIST is
only operating over:

          (let ((score (funcall fn obj)))
            (cond ((> score max)
                   (setq max    score
                         result (list obj)))
                  ((= score max)
                   (push obj result)))))

4. I can instantly see that SCORE is bound only within this form:

            (cond ((> score max)
                   (setq max    score
                         result (list obj)))
                  ((= score max)
                   (push obj result)))))

5. And finally I can instantly see that there are two test conditions, the
first being (> score max) and the second (= score max). Again by the
indentation I can see the return results grouped with the test conditions.

In pulling apart these forms there are still dangling parentheses
remaining on the page. That's the point. You can read the semantics
through knowledge of the special forms and the indentation alone. I didn't
attempt to manually delete the parentheses without the assistance
of an appropriate editor because I would probably screw something up. But
it did not stop me from being able to read the code.

Regards,
Adam




More information about the Python-list mailing list