a style question

Jim Mann jmann at angmar.sw.stratus.com
Wed Oct 3 03:28:26 AEST 1990


In article <1990Oct2.163853.17004 at nntp-server.caltech.edu>,
manning at nntp-server.caltech.edu (Evan Marshall Manning) writes:
|>henry at zoo.toronto.edu (Henry Spencer) writes:
|>
|>If Henry asks it must not be as self evident as I thought.  Hasn't this
|>ever happened to you:  You're thinking that you could apply what you
|>just learned on the net and 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?  I'll just search for the letter 'i' through 100 lines of
|>source."  You find that a lower case 'i' appears an average of about
|>four times per comment line.  'ix' appears in the comments only when
|>the comments are about variable 'ix'.  Or, similarly, you 'grep' 'i'.
|>
If you are using the variable for something other than just a loop counter,
you probably want to give it a better name than i or ix anyway. Yes, ix
is easier to grep for or search for, but it is no easier than i to figure
out when reading through the code.  (In fact, it is probably less easy. If
I see i, I generally assume that it is probably some sort of simple counter.
If I see ix, I'll probably spend some time wondering why the programmer
called it ix, what x stands for, etc.)
                                    

Jim Mann
Stratus Computer
jmann at es.stratus.com



More information about the Comp.lang.c mailing list