Why don't people like lisp?

james anderson james.anderson at setf.de
Sun Oct 19 11:33:42 EDT 2003



Pascal Costanza wrote:
> 
> Marcin 'Qrczak' Kowalczyk wrote:
> 
> > 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.
> >
> > Here is a straightforward translation into my dream language; note that
> > there aren't a lot of parens despite insignificant indentation and despite
> > using braces (like C) instead of bracketing keywords (like Pascal):
> >
> > def mostn Fun [] = [], null;
> > def mostn Fun (First\List) {
> >    var Result = [First];
> >    var Max = Fun First;
> >    each List ?Obj {
> >       let Score = Fun Obj;
> >       if Score >  Max {Max = Score; Result = [Obj]}
> >       if Score == Max {Result = Obj\Result}
> >    };
> >    reversed Result, Max
> > };
> 
> Apparently, Paul Graham doesn't like CLOS nor the LOOP macro. Here is
> another verson in Common Lisp (and this is not a dream language ;):
> 
> (defmethod mostn (fn (list (eql nil)))
>    (declare (ignore fn list))
>    (values nil nil))
> 
> (defmethod mostn (fn list)
>    (loop with result = (list (car list))
>          with max = (funcall fn (car list))
>          for object in (cdr list)
>          for score = (funcall fn object)
>          when (> score max) do (setq max score
>                                      result (list object))
>          when (= score max) do (push object result)
>          finally return (values (nreverse result) max)))

i must admit, that i share this imputed aversion. you see, loop does something
counterproductive in the conventional formatting: it makes language constructs
which have different semantics and/or different scope appear similar. this is
something which m.kowalczyk, despite the thougtful exposition, fails to
understand. to have not been able to characterize the respective indentation
with any more precision than "in the middle of lines" indicates a deficiency
in reading comprehension.

there is a difference between an operator, an argument, a binding, an
antecedant, a consequent, etc. the conventional lisp indentation enables the
literate reader to assign these roles directly upon comprehending the operator
and - surprise, surprise - the indentation, and without having to comprehend
the content of the dependant form. this means that the reader need attend to
the dependant form only if that is their actual focus.

the form of the loop macro interfers with this.
as does the conventional formatting of the posted python example.

ps, if the cond is that simple, one might consider

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

...




More information about the Python-list mailing list