On Sat, Nov 17, 2012 at 2:01 PM, Sean Silva <[email protected]> wrote: > > > ================ > Comment at: lib/Format/Format.cpp:49 > @@ +48,3 @@ > + // Start iterating at 1 as we have correctly formatted of Token #0 above. > + for (unsigned i = 1, n = Line.Tokens.size(); i != n; ++i) { > + bool InsertNewLine = Line.Tokens[i].NewlinesBefore > 0; > ---------------- > Daniel Jasper wrote: >> Sean Silva wrote: >> > These variables should be capitalized. >> You mean as opposed to pretty much every example on >> http://llvm.org/docs/CodingStandards.html? >> >> Also, they use e, not n, so I am going to change that back. > This wouldn't be the first time the coding standards document would be out of > date with its own advice *sigh*. > <http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly> > very clearly states that variable names are upper camel case. I'm currently > preparing a patch to fix the examples to comply with the docs. > > Using N as the end seems to be more common recently in the clang codebase, > although it really doesn't matter and isn't worth bikeshedding over. > > ``` > sean:~/pg/llvm/llvm/tools/clang % git log --since='6 months ago' > --pickaxe-regex --oneline -S'for.*unsigned.*\bI\b =.*N =' | wc -l > 25 > sean:~/pg/llvm/llvm/tools/clang % git log --since='6 months ago' > --pickaxe-regex --oneline -S'for.*unsigned.*\bI\b =.*E =' | wc -l > 5```
I'm not claiming that convention or the coding standards document accurately reflect this, but it has been the express desire of many developers to *not* see loop *index* variables capitalized. The goal is that loops with an index variable use a different naming convention to loops over an iterator, and LLVM and Clang both heavily use I and E as the names of the induction and end-point iterators. I have seen 'i' and 'e' for index variables, and 'Idx' and 'Size'. I prefer the latter, but find both to be acceptable. The only name I am opposed to is 'I'. Only an iterator should get that name. _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
