One more point regarding = and == (more flamage)

Leslie Mikesell les at chinet.chi.il.us
Wed Mar 27 04:42:45 AEST 1991


In article <925 at isgtec.UUCP> robert at isgtec.UUCP writes:
>|>  a) while (*foo++ = *bar++)
>|>  b) while (*foo ++ == *bar++)
>|>  c) while ((*foo++ = *bar++) != 0)

>Well the biggest argument has been if you use a) the maintainer can't tell
>if you meant a) or b);  if you use c) the maintainer KNOWS you meant a).
>This isn't rubbish.

If you assume that the programmer didn't make a mistake (i.e. typed
what he was thinking), then a) is just as obvious as c).  If you
assume that he did make a mistake, then c) is probably more likely
to be wrong that a).  More characters = more chances to screw up.

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.lang.c mailing list