??? 10/28/08 14:25 Read: times |
#159418 - one-char index isn't a problem Responding to: ???'s previous message |
I regularly use my one-letter x,y or i,j or whatever.
In a huge number of cases, the intention of an index variable is obvious from it's usage: bitmap[x][y] = value; row[i] = my_text; event_queue[i] = modem_event; ... There is no problem using one-character variables. But only if the code is written in a way where it is obvious that the variable is just an index to scan through a known array or similar. And more importantly: hard-coded numbers are so very, very dangerous. It is impossible to understand what the comparison does. And it is easy to forget to update all hard-coded constants when modifying the code. And a search may find many collisions since a digit 7 can mean so many things at different places in a big code file, while LAST_SCANLINE should only mean one thing. |