A brace vs. indentation hypothesis (was Re: Braces are not Compiler-Fluff.)

Tony Field tony at ajfcal.UUCP
Sat Jan 21 03:56:32 AEST 1989


I cannot really understand the religious insistance on programming style
in this news group.  It seems to me that *poorly written code* is, by
definition, poorly written.  The corollary of *nicely written code* being
nice immediately follows.

For every hypothesis on braces, you will always find situations where the
hypothesis fails.  The course of action should NOT be to reject the
hypothesis - but to adjust to hypothesis to allow for the new situation.

For example, Chip Salzenberg uses a  brace style of 
>
>	if (condition)
>	{
>	}
>
>makes the "if" and "{" adjacent.
> 

This makes good sense (but not necessarily my choice).

Blair Houghton's comment regarding the difficulties can be easily corrected
by using Chip's suggestion of *vertical space* plus horizontal space:

>     if (condition && much longer
          ---- etc -------
> 	fects)
> 	action();
>     {
> 	volatile gas;
> 
> 	fprintf(stdmess,"Don't light that match!");
> 	explode(gas);
>     }

now becomes:

>     if (condition && much longer
>   	       conditional expression sequence
> 	       than is really excusable, with strange arrangement ef-
> 	       fects)
> 	action();
                             <<<<<< insert blanks for vertical separation.
                                    maybe additional indentation FOR THIS
                                    EXAMPLE is needed in the 'if' statement.
>     {
> 	volatile gas;
> 
> 	fprintf(stdmess,"Don't light that match!");
> 	explode(gas);
>     }

also:

>     for (boo = foo; boo < eleventeen(foo); boo +=azillion);
>     {
> 	---- etc -----
>     }

becomes:

>     for (boo = foo; boo < eleventeen(foo); boo +=azillion)
	  ;
>     {
> 	---- etc -----
>     }

I find it rather interesting that Blair DOES use vertical space
to separate variable declarations from proceedural code, but DOES NOT
seem to wish to use vertical space between lines of proceedural code.


I have seen *excellent* code written in almost every coding style and
in many different languages (even Fortran, PL/I, and Cobol).

The degree of excellence is directly related to the talent of the
programmer:  if he/she THINKS CLEARLY, she/he will WRITE CODE CLEARLY.

You cannot legislate talent or ability by use of standards.

                       .... tony ....

P.S.	For the religious, I have a DOGMA that I believe in:

	And GOD invented white space: blessed are those who use white
	space with care and attention - even for APL.
-- 
+------------------------------------
|  Tony Field                       ..alberta!calgary!xenlink!ajfcal!tony
|  Calgary, Alberta, Canada



More information about the Comp.lang.c mailing list