[llvm-commits] [llvm] r137497 - /llvm/trunk/docs/CodingStandards.html

David Blaikie dblaikie at gmail.com
Fri Aug 12 13:39:50 PDT 2011


> My proposed rule would be that all variables and fields *except*
> local variables should be capitalized.

For myself that feels much like more strict senses of hungarian -
encoding scope information into identifiers. (granted at my day job I
have to stick to a convention like that ("m_") which is what it is -
though if I had to differentiate I'd probably use something like that
(m_fooBar or _fooBar (the latter gets tantalizingly close to stepping
on compiler reserved names, of course)))

I do like variables to be differentiated from types, though. But I
suppose C++ syntax doesn't leave as many ambiguities around "is that a
type" as, say, C#/Java do ("FooBar.baz()" - is it a static or
non-static method call?). The place where that comes up in C++ is more
"FooBar(x, y)" - is FooBar a variable with an op() overload, or
function, or a type being constructed? I suppose in some sense you
shouldn't care (moreso between op() v function, if something overloads
op() it's trying to look like a function anyway).

[& my major prevailing coding convention is "whatever the standard
library for the language I'm writing uses", so my code fits in with
standard library usage seemlessly - but that's clearly out the window
here & I can certainly understand why the standard C++ naming
convention isn't terribly helpful (lowercase with underscore
separators for everyone! so no differentiation of types, namespaces,
variables, etc)]

- David



More information about the llvm-commits mailing list