| ▲ | jonahx 2 hours ago | ||||||||||||||||
> but ijk I will rail against until I die. > There's no context in those names to help you understand them, you have to look at the code surrounding it. Hard disagree. Using "meaningful" index names is a distracting anti-pattern, for the vast majority of loops. The index is a meaningless structural reference -- the standard names allow the programmer to (correctly) gloss over it. To bring the point home, such loops could often (in theory, if not in practice, depending on the language) be rewritten as maps, where the index reference vanishes altogether. | |||||||||||||||||
| ▲ | vilos1611 2 hours ago | parent [-] | ||||||||||||||||
I respectfully disagree. The issue isn't the names themselves, it's the locality of information. In a 3-deep nested loop, i, j, k forces the reader to maintain a mental stack trace of the entire block. If I have to scroll up to the for clause to remember which dimension k refers to, the abstraction has failed. Meaningful names like row, col, cell transform structural boilerplate into self-documenting logic. ijk may be standard in math-heavy code, but in most production code bases, optimizing for a 'low-context' reader is not an anti-pattern. | |||||||||||||||||
| |||||||||||||||||