Personal style -vs- Standards

Dale Schumacher dal at midgard.Midgard.MN.ORG
Tue Dec 20 04:27:51 AEST 1988


In article <17082 at dhw68k.cts.com> allan at dhw68k.cts.com (Alan Perry) writes:
[talking about indentation depth...]
|I always thought 4 with the correct answer.  Ever since I first starting
|writing in C I have used 4-space indentation.  I started doing it this
|way because all of the C code written by others where I went to school
|was indented by 4.
|
|I don't know where this indent by a full tab came from, but I have a
|problem controlling my gag reflex whenever I see it.

Gack!  There are many other things in reading other people's C code that
should bother you more the differences in tab size.  I have ported code
from all sorts of sources, and it's rarely the coding style that gets in
the way (a former employer wrote C with NO indentation).

Now a proposal... one that I'm sure many of you have thought about in the
past.  Given, each of us has a coding style that we prefer to use, be it
adaptation to local coding standard, "baby-duck" syndrome (see above) or
personal rationalization.  Given, this style is rarely the same (sometimes
not even similar) to the style used by a reader of your code.  Given, a
huge amount of time is "wasted" reformatting code that you didn't write
just so you can understand it.  Proposed, what is needed is a program
which understands C syntax and can use a template to reformat C source
into a form described by that template.  I know, this is DEFINATELY a
non-trivial task.  Comments are one of the biggest problems, for example.
However, with all of the resources touched by this newsgroup, it would
seem that this could be accomplished.  It's value is, at least to me,
obvious.  I would suggest looking into things like the processing that
'tbl' or 'eqn' use to treat this as a page formatting problem with the
comments (hanging comments, that is) being column align text.  Even if
the comments AREN'T handled nicely, just getting the format of the code
itself into reasonable shape is a big head start.  So far, the 'cb' type
programs I've seen have the major disadvantage that the formatting rules
are hard coded and even at that, don't seem to do a very good job of
fully converting to a consistent style.  I'd be glad to work on something
like this, but I don't think I want to do it alone.



More information about the Comp.lang.c mailing list