more about programming style

Frank Adams franka at mmintl.UUCP
Tue Jul 16 04:26:21 AEST 1985


In article <68 at ucbcad.UUCP> faustus at ucbcad.UUCP (Wayne A. Christopher) writes:

> if you write
>
>	while (p->duck)
>		p++;
>
>instead of
>
>	while (p++->duck)
>		;
>

This will probably not be the only posting pointing out that your examples
are different.  The first will leave p pointing to the first structure for
which duck is zero; the second leaves it pointing one past it.

The ease with which this kind of mistake can be made in c by an experienced
c programmer, and the difficulty of finding such mistakes, is to me
the main weakness of c.

To me, serious programming does not mean playing with a piece of code to
get every last instruction cycle out of it, (nor writing as many lines
of code as possible, the opposite fallacy), but getting as much function
implemented as quickly as possible.  (Note that code that runs too slowly
is not functional.  Usually this happens when excess I/O is being done.
There are relatively few places where saving an instuction or two is
worthwhile - and those should be extracted in small subroutines (e.g.,
strcpy) which can be written in assembler if necessary.)



More information about the Comp.lang.c mailing list