a style question

Ken Lerman lerman at stpstn.UUCP
Tue Oct 2 23:41:53 AEST 1990


In article <1990Oct1.174625.22061 at zoo.toronto.edu> henry at zoo.toronto.edu (Henry Spencer) writes:
->In article <1990Sep30.220839.20183 at nntp-server.caltech.edu> manning at 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.
->
->There is an old prejudice against using "I" or "O" for a variable name,
->arising from confusion with "1" and "0", but the lowercase letters don't
->have that problem.
->-- 
->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

I think I first saw this in one of Jerry Weinberg's books.  Don't use
two variable names which differ in only a single character.  That way
a one key typo won't hurt you.  If you use a lot of single character
variable names, one miskey and you have a syntactically valid program
which does the wrong thing.  Of course, using ix and iy has the same
problem.  Are "row" and "column" better variable names?  Probably, but x and y are more convenient. :-) Do what I say, not what I do. :-)

Ken



More information about the Comp.lang.c mailing list