by hollerith · 14y ago · 0 comments
Lisp coders are accustomed to a certain pattern of indentation that would be analogous to the following in C, where xxx and yyy are typically many lines long:
while(aa){if(bb){
xxx}
yyy}
I am recommending for Lisp coders to avoid that pattern and to indent the above as follows: while(aa){
if(bb){
xxx}
yyy}
which is of course familiar to a C programmer and which we will refer to as "formula A". However, what will be unfamiliar to a C programmer is the motive behind my recommendation: namely, to make it possible to introduce into Lisp a new pattern of indentation, unfamiliar to C programmers and Lisp programmer (but familiar to Haskell programmers) in which you are allowed to write, while(aa){if(bb){
xxx}}
where again xxx is a place holder for many lines of code. However, it is important to note that the following would be a definite violation of the indentation style I recommend: while(aa){if(bb){
xxx}
yyy}
I recommend indenting that as formula A above. In other words, you can begin multiple multi-line s-expressions on the same line, but if you do, you have to close all of those multi-line s-expressions at the same time.>maybe you can post it anyways?
It's a little too long: about 90 lines of code. I could make it shorter by taking out the code that warns the user of the stylistic violation described above, but most user would want that code.
Anyways, this:
while(aa){if(bb){
xxx}
yyy}
is not banner-style indent, whereas this: while(aa){
if(bb){
xxx}
yyy}
is.It's a little too long: about 90 lines of code
Not too long for Bitbucket.
This "lisp style indenting" happens in Haskell every now and then too -- luckily all the big projects I looked at use fixed size indent. It's usually a sign of a programmer who hasn't written a lot of code, but I bet someone reading this will find some guy as good as Simon Marlow doing exactly that.