3 ms·
When you use i and j as loop indices, everybody knows what you're talking about. It's idiomatic. How is that bad variable naming if its the clearest thing for e
by sketerpot 17y ago
When you use i and j as loop indices, everybody knows what you're talking about. It's idiomatic. How is that bad variable naming if its the clearest thing for everyone?
- nailer 17y ago> How is that bad variable naming if its the clearest thing for everyone? The clearest thing for me would be: channel.open() Which indicates to me that a channel is being opened. Rather than i.open() Which means nothing to me unless I find and read some other line.
- alextgordon 17y agoNobody's suggesting that i and j be used for anything other than loop counters: integers. In fact they come from FORTRAN, where a variable starting with a letter [i-n] was an integer, whereas variables starting with other letters were floats. Personally, I much prefer the certainty of the current situation to the relative uncertainty of a free-for-all. That and for (counter = 0; counter < N; counter++) seems very longwinded.
- RodgerTheGreat 17y agoMaybe this is just a personal thing, but it always struck me as odd that the recommended variable names for loop counters are the two letters that look most similar to a semicolon. I tend to use x and y.
- nailer 17y ago> Nobody's suggesting that i and j be used for anything other than loop counters: integers You're right, I missed the 'indices' part of your original comment. Unfortunately I've worked at a couple of places where they're used in every for loop.