help explaining rationale for indentation

Grant Griffin g2 at seebelow.org
Tue Aug 22 17:01:42 EDT 2000


Penfold wrote:
> 
> The irony of this particular criticism is that most C++ programmers use
> indentation anyway ... anyone claiming that
> class X
> {
> double x()
> {
> if (1)
> {
> while (1)
> {
> blah()
> }
> }
> }
> }

Right.  If you're doing indenting anyway, why not take credit for it?
<wink>

When I first translated a simple C algorithm into Python, I was amazed
at how much disappeared.  Much of that, of course, was braces.  Then,
one wonders: Why did we need all that stuff in the first place?

If we all lived in a programming world where indentation was the norm
(BTW, why hasn't anybody ever offered a braceless version of C/C++), I
think braces would be a *VERY* tough sell.  People would say, "Why do we
need that?--all it does is clutter our code and lead to multiple ways of
writing the same thing."

I think Tim made the point once that although there are umpteen
different ways to place braces, you'll notice that there's only one way
to do block formatting in Python.  But don't despair: fortunately,
Python is kind enough to give us a few things to fuss with each other
about: how many spaces to use per indent, whether to use hard or soft
tabs--oh, and whether indenting is the Achilles heel of this language or
whether it's part of what puts the spring in Achilles step. <wink>

I had an discussion today with a collegue about coding style in C
(including brace placement); my point was that since coding style is
semi-arbitrary anyhow, the best way to decide among the many differing,
but defensible choices is to simply use the canonical example provided
by the Prophets K&R.  My collegue remained unconvinced.

(do-ya'-think-i-should-try-to-sell-him-python?-<wink>)-ly y'rs,

=g2
-- 
_____________________________________________________________________

Grant R. Griffin                                       g2 at dspguru.com
Publisher of dspGuru                           http://www.dspguru.com
Iowegian International Corporation	      http://www.iowegian.com



More information about the Python-list mailing list