Proposal for a scientific look at C style choices

Mark A Terribile mat at mole-end.UUCP
Sat Jan 7 22:46:30 AEST 1989


> :Hmm.  Do you mean that you have never written
> :
> :#if ...
> :#  if ...
> :. . .
> :#  else
> 
> Well, I understand dpANS allows the "#" to be the first non-blank character
> on the line, rather than precisely the first, so this could be done in the
> normal obvious way in a compliant compiler.  I believe that that's what I've
> done when I nest conditionals (not too often, obviously).

dpANS is not yet universal.  Besides, I really DO prefer to see the # in the
first column so that I can scan for the conditional compilation grunge right
away--and so that I don't miss some effect of it later on while scanning the
code for something else.
 
> 
>     if (((a->op == XNES_step) && (a->size <= XNES_bufsize)) ||
>       ((a->op == XNES_fix) && ((a->size + a->leftover) <= XNES_bufsize))) {
> 	/* code */
>     }
> For a more complex expression I would tend to indent blocks as indicated
> by the parenthasization of the expression.

Indenting isn't a bad idea.  But is it a good idea to use so many redundant
parens?  When I put parens in, I *mean* them to be there; I *mean* that the
normal, usually correct (ok, except for bitops .vs. relops and equops)
precedence is violated; in their absence, default thinking and default
perception will do just fine.

Do you *really* want to bury the conjuntive/disjuntive operators at the
end or in the middle of the line?  In C they short-circuit, so they have
some flow control responsibility, but in any language their effect is more
a matter of control structure in most instances than it is a matter of
simple value computation.  (My opinion, of course.)  Given that, it makes
sense to keep them up-front and visible.
 
> :(Ok, even nroff wouldn't have put the ``)'' at the beginning of a line.  I
> :have seen it done by programmers, however.)
> 
> Ucky poo.  Blecch.

My feelings exactly--the first few times.  After that, my disgust reaches the
heavens and my exclamations reach the floor above.
-- 

(This man's opinions are his own.)
>From mole-end				Mark Terribile



More information about the Comp.lang.c mailing list