Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!ames!excelan!donp From: donp@na.excelan.com (don provan) Newsgroups: comp.lang.c Subject: Re: a style question Message-ID: <2039@excelan.COM> Date: 2 Oct 90 19:22:04 GMT References: <7341@darkstar.ucsc.edu> <8660@ncar.ucar.edu> <1990Sep30.220839.20183@nntp-server.caltech.edu> <1990Oct1.174625.22061@zoo.toronto.edu> Sender: news@excelan.COM Reply-To: donp@novell.com (don provan) Organization: Novell, Inc., San Jose, California Lines: 24 In article <1990Oct1.174625.22061@zoo.toronto.edu> henry@zoo.toronto.edu (Henry Spencer) writes: >In article <1990Sep30.220839.20183@nntp-server.caltech.edu> manning@nntp-server.caltech.edu (Evan Marshall Manning) writes: >>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... > >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. The reason both are meaningless is because there *is* no context: this is just a code fragment. In practice, i've never encountered a loop that wasn't counting *something*, so why not name it? I agree that "ix" is nearly as bad as "i", and "loopindex" is worse than either. The fact that this variable is an index is its *least* interesting attribute. An index into *what*? *That's* the important point. My attitude is just the opposite of yours: to me, the shorter the loop is, the less excuse there is to choose a name because of it's length. If you're only going to be typing the name three or four times, what's the advantage keeping it a single character? Readability? don provan donp@novell.com