3 ms·
"If anyone even hints at breaking the tradition honoured since FØRTRAN of using i, j and k for indexing variables, namely replacing them with ii, jj and kk, war
by jmpeax 11y ago
"If anyone even hints at breaking the tradition honoured since FØRTRAN of using i, j and k for indexing variables, namely replacing them with ii, jj and kk, warn them about what the Spanish Inquisition did to heretics."
Hold on, should we use i instead of ii, or not use it? I fucking hate these double-negative articles.
- GeneralMayhem 11y agoThe article is saying not to mess with the "religious" tradition of i/j/k, which means that the author actually things that ii/jj/kk are better. I don't think it's hard to follow, really, unless maybe if English isn't your first language.
- billforsternz 11y agoThis is a weird one. Using i,j,k for loop values is fine, especially tight inner loops. I can't see that ii,jj,kk adds anything. And I don't see much point in using verbose names like innerLoopIterator or arrayIdx or whatnot for these type of variables either. Actually later on in rule 20 he implies (with negative logic of course) that i is actually a good inner loop variable name. So that's an inconsistency right there.
- pacaro 11y agoii, jj, and kk, are easier to search for (although I have jj mapped to <ESC> in vim...) index, jndex, and kndex, are preferred, obviously.
- belovedeagle 11y agojj = <ESC> changed my life; I'm not even joking. I even went so far as to put my zsh in vi mode and added jj there too. (WARNING: doing this will result in a pathological need to type jjk whenever you open a shell to start scrolling through history.)
- ajuc 11y agoIf you have to search for loop index variable, your code has worse problems than naming. I mean - I don't recall writing a loop longer than 2 screens in years. Usually a loop is less than half a screen long. And anyway, you can search for [^\w]i[^\w] if you really need to. Maybe it's aquired taste, but in array-heavy code (usually math-related) I much prefer A[i][j][k] * B[j][k][i] than the same with long names for index variables.
- carlob 11y agoor \bi\b