🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #4165

Tradition Lisp code formatting

#4165
From: ....What Is?....
Date: Sun, 23 Jun 1991 04:55
66 lines
2951 bytes
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 |
Technical Details
Message-ID: <20899@sdcc6.ucsd.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!ucsd!sdcc6!sdcc13!sboswell

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!ucsd!sdcc6!sdcc13!sboswell
From: sboswell@sdcc13.ucsd.edu (....What Is?....)
Newsgroups: comp.lang.misc,comp.lang.lisp,comp.lang.c
Subject: Tradition Lisp code formatting
Message-ID: <20899@sdcc6.ucsd.edu>
Date: 23 Jun 91 04:55:34 GMT
Sender: news@sdcc6.ucsd.edu
Followup-To: comp.lang.lisp
Organization: UC San Diego -- 1991 "Wannabe Real College" finalist
Lines: 66