a style question

Henry Spencer henry at zoo.toronto.edu
Thu Oct 4 04:09:39 AEST 1990


In article <1990Oct2.163853.17004 at nntp-server.caltech.edu> manning at nntp-server.caltech.edu (Evan Marshall Manning) writes:
>>In what way is "ix" superior to "i"?  Both are meaningless names in
>>this context.  If the name is not going to be meaningful -- and in the
>>context of a short loop, it's not clear that making it meaningful is
>>either possible or particularly important -- then at least keep it short.
>
>... speed up this time-critical bit of code by
>changing the original cout-up loop to a count-down loop.  "But wait," you
>say, "What if some later code depends on the value of 'i' after exiting
>the loop? ...

Two observations:

1. There is much to be said for search primitives that know about word
	or token boundaries.

2. Variables used over wide sections of code need more attention to clear
	naming than variables used only in a short loop.

>Doesn't this happen to anybody else?  (I know Henry gets it all right
>the first time, but even he must inherit code, and inherited code
>always has declarations like "int    i,j,k,l,ii,jj,kk,ll,m;" and no
>comments :-)

Coding rules are no substitute for competence.  Incompetently-written code
is a pain to maintain whether or not its author followed some well-meant
set of rules.
-- 
Imagine life with OS/360 the standard  | Henry Spencer at U of Toronto Zoology
operating system.  Now think about X.  |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list