Path: utzoo!attcan!uunet!jarthur!nntp-server.caltech.edu!manning From: manning@nntp-server.caltech.edu (Evan Marshall Manning) Newsgroups: comp.lang.c Subject: Re: a style question Message-ID: <1990Oct2.163853.17004@nntp-server.caltech.edu> Date: 2 Oct 90 16:38:53 GMT References: <7341@darkstar.ucsc.edu> <8660@ncar.ucar.edu> <1990Sep30.220839.20183@nntp-server.caltech.edu> <1990Oct1.174625.22061@zoo.toronto.edu> Organization: California Institute of Technology, Pasadena Lines: 36 I wrote: >Don't ever use single-character variable names. I use 'ix' for >loop index variables for which I can come up with no better name... henry@zoo.toronto.edu (Henry Spencer) 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. 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'. What's actually happened to me more often is that lint tells me that a variable is not used in a procedure but I want to check that it is not used in any #ifdef'd code before removing the declaration. 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 :-) *************************************************************************** Your eyes are weary from staring at the CRT for so | Evan M. Manning long. You feel sleepy. Notice how restful it is | is to watch the cursor blink. Close your eyes. The |manning@gap.cco.caltech.edu opinions stated above are yours. You cannot | manning@mars.jpl.nasa.gov imagine why you ever felt otherwise. | gleeper@tybalt.caltech.edu