Subject: Why the default Scheme/LISP identation is not like C?

From: Shlomi Fish <[email-masked]>
Date: Thu, 2 Nov 2000 17:33:28 +0200 (IST)

What I find most distressing in reading other people Scheme or LISP code
is that all the ending parenthesis are placed on the same line.

What I think would be a better style is to do it like C with the Linux
kernel code style. Hence, put each parenthesis directly beneath its
opening parenthesis on a separate line.

(define mysum
(Y (lambda (f)
        (lambda (x)
                (((((less-or-equal (var x)) (top x))     ; If var x < top
x
                        ; If part
                        (lambda (no_use)
                        (f 
                                (((make-mysum-list 
                                        (top x)) 
                                        (succ (var x))) 
                                        ((add (result x)) (var x))
                                )
                        )
                        ))
                        ; Else part
                        (lambda (no_use)
                                x
                        )) 
                                zero ;  Pass zero as argument to no_use
                )
        )
)))

You can see more examples here:

http://vipe.technion.ac.il/~shlomif/lecture/Lambda-Calculus/

Are Schemers wish to spare themselves and/or the interpreter the extra
space required to use the newlines and the whitespace? Arguably the same
can be said about C but you don't see C program having a "}}}}}" sequence.

Best regards and "Done Guard",

	Shlomi Fish

BTW, when designing sawfish, its creator created an entirely new variant
of LISP which had lexical scoping and which was not Scheme. It's called
rep. I think it would have been much easier to learn Scheme, and maybe add
some primitives to it, than to do all that coding. IMO, it's pathetic.

----------------------------------------------------------------------
Shlomi Fish        [email-masked] 
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       [email-masked]

The prefix "God Said" has the extraordinary logical property of 
converting any statement that follows it into a true one.

---

From: Moshe Zadka <[email-masked]>
Date: Thu, 2 Nov 2000 17:35:22 +0200 (IST)

> is that all the ending parenthesis are placed on the same line.

Anyone having ) on seperate lines hasn't learned t use his editor
properly.

> can be said about C but you don't see C program having a "}}}}}" sequence.

That's because the sequences are shorter and more seldom in C, and C isn't
as easily real-time parseable, so you need to help human editors too.

--
Moshe Zadka <[email-masked]> -- 95855124
http://advogato.org/person/moshez

---

From: Shlomi Fish <[email-masked]>
Date: Thu, 2 Nov 2000 19:08:07 +0200 (IST)

> Anyone having ) on seperate lines hasn't learned t use his editor

Well, first of all not all editors support matching parenthesis, and in
some (e.g: vim) they are not highlighted automatically. Second of all, I
would also like to see where one construct starts and ends, because I may
browse it with my webpage or view it with less and so forth.
 
> as easily real-time parseable, so you need to help human editors too.

If such sequences are common in Scheme , then there's all the more reason
to indent them C style. And on the same logic, we might wish not to indent
at all.

Regards,

	Shlomi Fish

> To unsubscribe from this group, send an email to:
> [email-masked]
> 
> 
> 
>

---

From: Omer Musaev <[email-masked]>
Date: 02 Nov 2000 18:10:16 +0000

Coding style is one of many components in language culture. 

For example, following style is common in C but would be considered 
a very bad practice in other language:

if ( ! ( db_server = create_db_server ( db_server_t ) ) )
     return NULL ;

db_server -> run () ;

Note the assignment inside 'if' predicate 

In that fashion, lisp code is buid of "triangles". That coding style reflects
sexp-oriented editors that are not-so-available today. That lack of reflected 
entity can be misunderstood into bad practice.

But there are more:

Most code in C is based on statements, i.e. control flow is important.
Thus, deep nesting is discouraged. In addition, C is very close to some 
generic assembly language, and must represent that.

Scheme, on the other side is based on values. I.e. that is really not important 
what is the order of evaluation. What is important is that all values you 
need for another value should be determined before.

Thus, 
(
 (lambda (x)
   (letrec
     (
       (xx
         (lambda (x)
           (+ x 1)
         )
      )
    (xx x)
  )
1 
)

looks annoying, and does not tell anything about, while

((lambda (x)
  (letrec
    ((xx (lambda (x)
          (+ x 1)))
   (xx x))  1)

explains clearly what is done.

Note that: 
letrec ribs are clearly visible
application of xx on x is also cleary visible
last value is the most important, since that is the value of expression, 
and thus it just does not matter how many parenthice are there.

And note the very main point - the whole expression is just one expression!!
and not 4 or 6.