Subject: Scheme in C Indentation Cont.

From: Shlomi Fish <[email-masked]>
Date: Wed, 13 Mar 2002 09:13:36 +0200 (IST)

I talked with the homework exercises checker of my "Structure and
Interpretation of Computer Programs" course, and he told me that my
exercises were very hard to follow. For a moment I got nervous that my
code was bad, but then he told me that the reason was that I placed every
right parenthesis on its own line. Like this:

<<<
(define (my-print-list mylist)
    (define (helper idx mylist)
        (if (not (null? mylist))
            (begin
                (display idx)
                (display " ")
                (display (car mylist))
                (newline)
                (helper (+ idx 1) (cdr mylist))
            )
        )
    )
    (helper 0 mylist)
)

Naturally, the problem is that _I_ find it easier to write, read and
edit code like this. Plus, the lecturer said it was perfectly OK for me to
write it this way. And my grades for the homework turned out fine.

We recently had a talk in Philosophy-IL about people who treat packages as
an integrated whole vs. those who treat them as sets of independant
components. I believe that I never saw the traditional Scheme
indenendation as something that is inherent to the language, as I was
already used to other indentation schemes. Other people OTOH are a bit
"copy-cats" in the sense that they do exactly as they see it and do not
try to change the conventions. (This is not necessarily a bad thing)

I read OmerM's post about why the traditional LISP/Scheme indentation is
like that. I got his wave, but I still prefer it the C way, at least
when I have to edit code. So, each to his own way.

Regards,

	Shlomi Fish

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

"Let's suppose you have a table with 2^n cups..."
"Wait a second - is n a natural number?"

---

From: guy keren <[email-masked]>
Date: Thu, 14 Mar 2002 01:50:04 +0200 (EET)

> write it this way. And my grades for the homework turned out fine.

objection! homework grading is not something you should base your coding
style upon, or use to justify one coding style or miss-justify another.

(judge goes "sustained")

> try to change the conventions. (This is not necessarily a bad thing)

just like your C style which i would assme is a copycat of the style you
saw in C programs? how do you think you got used to these indentatino
schemes? you're mostly showing that in the past you were open minded (to
learn other people's indentation schemes) while now you're not?

> when I have to edit code. So, each to his own way.

no way hose. this is more then just 'personal taste'. you usually don't
code alone, but in groups. as such, you should know that consistent coding
style is important. and it foten does come with the language, since that's
what the other programemrs do - and you will have to adapt, not the world,
unless you wish to remain a lone wolf. for these people, who are used to
their indentation styles, using your indentation style looks odd and
not-productive.

btw, there is always a 3rd choice - don't ever program in lisp ;)
i think that when i learned lisp, i used this style too, for the same
reason (got used to it from ql's basic, pascal and c). on the other hand,
i never did learn to properly use lisp anyway (i dismissed use of any
non-recursive function, since it loked odd to me. i wrote all my code
using recursion, and got away with it). that's part of why i don't program
in lisp.

but i say "in rome - behave like a roman. don't loke it? don't go to
rome". for a _group_ of programmers, this makes more sense. you may still
dismiss some practices as bad, but not if they are so basic.

--
guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy