6 ms·
Examples of Lisp formatting through history
- siavosh 15y agoInteresting. Two trends I pick up on at glance: 1) increased use of indentation 2) abandoning commenting for self-documenting code (and the occasional header comment). I'm guessing these are pretty universal trends, no?
- drcode 15y agoI wrote my own indenter in EMACS for clojure 'cause I don't like the standard indentation of modern lisps. My indenter uses the "primitive" syntax-level indentation exemplified by the "Dream of a lifetime" code example from 1979 on this page. This is the ONE AND ONLY CORRECT INDENTATION STYLE for Lisp.
- lemming 15y agoThis is the ONE AND ONLY CORRECT INDENTATION STYLE for Lisp. Because the defining feature of Lisp is allowing only one way to do things?
- hollerith 15y agoCoding in Haskell changed the way I indent Lisp code. The way I intent now differs from most Lisp indentation styles in that (a (b (c (d (e (f (g (h xxx yyy (i uuu (vv ww qq) (j foo bar)))))))))) becomes allowed whereas (let ((a b) (c d)) foo) becomes not allowed -- you have to write it as (let ((a b) (c d)) foo) or (if you need the let clauses to line up) as (let ( (a b) (c d)) foo) Well, the let form is such a unusual case that I will give a second example: (f (g xxx yyy) zzz) becomes not allowed -- you have to write it as (f (g xxx yyy) zzz) or (if you need g's arguments to line up) as (f (g xxx yyy) zzz) Although I used two spaces for every new level of indentation above, the choice of the number 2 is of course not an essential element of the style.
- deleted 15y ago[deleted]
- spacemanaki 15y agoThat seems pretty strange, and some of those examples are really hard to read. Care to share some real Lisp code and not just (a (b (c ... ))) examples? And maybe some motivating examples in Haskell? I just can't see how any of these are an improvement and I'm curious.
- hollerith 15y agoIn Haskell it is not uncommon to see things like foo x y = x >>= \a -> case a of Leaf -> .. Branch aleft aright -> .. which translates into the Scheme pseudocode (define (foo x y) (bind x (lambda (a) (case a ((leaf) ..) (branch aleft aright) ..) Although such an indentation pattern (namely, multiple "unclosed" open parens on one line, which all get closed at once) is very uncommon in Scheme or Lisp code, I find it handy enough to trade off for certain other "competing" indentation patterns (namely, the one in the final example in grandparent) traditional in Scheme and Lisp. I have been meaning to put my .emacs.d (5800 lines) on Github. Do you want me to email you when I have done so?
- 15y ago
- roryokane 15y agoLink to the last example, from "Introduction to Newlisp, wikibook, 2012": http://en.wikibooks.org/wiki/Introduction_to_newLISP/Macros#Symbol_confusion http://en.wikibooks.org/wiki/Introduction_to_newLISP/Macros#...
- swang 15y agoThis is almost impossible to read on an iPhone. The text doesn't resize and whenever I try to scroll around it activates some blogger "next article" functionality
- arto 15y agoLikewise on an Android. Made for difficult reading.
- WildUtah 15y agoLook at all the commas! Clojure has been ahead of the curve on these commas, of course. Commas (and semicolons) are considered whitespace. They're available to pretty up your code's presentation however you like. It's like Clojure is committing in advance not to need many syntax characters.
- pwpwp 15y agoAhead of the curve? Other Lisps stopped using commas half a century ago.
- jhrobert 15y agoIs this the definite proof that Lisp in unreadable, no matter what?
- davidw 15y agoThe standard joke about how Lisp looks, which I believe comes from Perl's Larry Wall, is "oatmeal and toenail clippings". It's interesting to see the old ones even if one is not a big lisp fan, though.
- kinleyd 15y agoA very cool history of Lisp: while we see the changes in formatting styles over the years, we also see the personalities behind the progress of Lisp. Really nice!
- larsberg 15y agoNot all samples have numbers in them, but I was somwhat disturbed that it was not until 2012 that the LISP publishers used a monospace font that clearly distinguished 0 "zero" and O "capital letter o".
- mark_l_watson 15y agoThat was fun, but he missed InterLisp D. I got an Xerox 1108 Lips Machine in 1982, and InterLisp D was amazing!
- pmcjones 15y agoIt's there: http://instprog.com/blogposts/Few-Examples-of-Lisp-Code-Typography/1985.png http://instprog.com/blogposts/Few-Examples-of-Lisp-Code-Typo...
- pmcjones 15y agoA number of the documents he excerpted are available via http://www.softwarepreservation.org/projects/LISP/ http://www.softwarepreservation.org/projects/LISP/ .