Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!cs.umn.edu!uc!shamash!timbuk!dkozak From: dkozak@mahogany29.cray.com (Darryn Kozak) Newsgroups: comp.lang.lisp Subject: Re: Tradition Lisp code formatting Message-ID: <124942.14634@timbuk.cray.com> Date: 24 Jun 91 19:20:52 GMT Article-I.D.: timbuk.124942.14634 References: <20899@sdcc6.ucsd.edu> Sender: dkozak@mahogany29 (Darryn Kozak) Organization: Cray Research, Inc. Lines: 89 In article <20899@sdcc6.ucsd.edu>, sboswell@sdcc13.ucsd.edu (....What Is?....) writes: > I wanted to post this a long time ago but feared starting a flame war. > But my curiosity has finally gotten the better of me. I must know. :) > > How did the traditional style of Lisp code turn out to be so crunched > together? > > In languages like C, the trend has been to space everything out so > that blocks are visible (see GNU Emacs "c-mode" to see what I mean, > if you don't.) I find it much more readable like that. But in my > Lisp books, it seems, comparatively, smashed together! Here's an > example, from page 115 of _Lisp: 3rd Edition_ by Patrick Henry > Winston and Berthold Klaus Paul Horn: > > (defun count-outlyers (list-of-elements) > (let ((result 0)) > (dolist (element list-of-elements > result) > (when (or (> elements boiling) > (< element freezing)) > (setf result (+ result 1)))))) > > I would have formatted it this way: > > (defun count-outlyers (list-of-elements) > (let > ( > (result 0) > ) > (dolist > (element list-of-elements result) > (when > (or > (> element boiling) > (< element freezing) > ) > (setf result (+ result 1)) > ) > ) > ) > ) > > Whether to split and indent the (element list-of-elements result) is > usually a matter of whether or not the one-line version makes the > functionality immediately obvious, to me. But to me, the functionality > of let seems much more obvious; the local variable "result" has been > created, and it's used inside a dolist. (Incidentally, the only > reason I put the defun's argument list in the same line is so I can > do "grep '(defun' file.lisp" from csh to get a list of all the function > prototypes in the source file.) > > So far, I've only found one other person who formats the way I do, > and he hates Lisp nowadays :-( so although it's not a very scientific > conclusion, I'd say there's at least a chance of programmers being > turned off by Lisp because they feel lost in all the parentheses and > cannot immediately divine the structure. (He would get his Lisp > assignments back from the TA, re-formatted to the traditional way :) > > I crossposted to a few seemingly unrelated newsgroups in the hopes > of finding people who were disenchanted with Lisp, to ask if this > was part of the reason. > > Please give me your thoughts on this. No Holy War(TM) intended. :-| > > Steve Boswell | This opinion is distributed in the hopes that it > whatis@ucsd.edu | will be useful, but WITHOUT ANY WARRANTY... > whatis@gnu.ai.mit.edu | I prefer the "smashed" look myself, both for Lisp and C. And there's no need for a Holy War, because I'm right (just a joke folks). Have a nice day, Darryn J Kozak Cray Research Park 655F Lone Oak Drive Eagan, MN 55121 USA dkozak@cray.com (612) 683-5244 ISS (Integrated Support System) Project