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

John McCall rjmccall at apple.com
Fri Aug 12 15:02:10 PDT 2011


On Aug 12, 2011, at 1:39 PM, David Blaikie wrote:
>> 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.

Yes, in the sense that they're both using naming conventions to
represent distinctions that the type system doesn't directly make.
The specific idea of distinguishing locals from non-locals is
pretty common to a lot of naming conventions, most of which
don't otherwise adopt anything like Hungarian notation.  Certainly
I'm not proposing that we adopt it.

The traditional argument against Hungarian notation is that it's
complex but unenforced form of type-checking, and that it's nearly
always better to make the actual type system do this form you.
That doesn't apply here because, first, there's no way to make
the type system care about fields vs. locals, but second and more
fundamentally, this is not about catching mistakes arising from
inappropriately using a local/non-local;  it's about making the
behavior of code clearer to readers who haven't already
internalized its idioms.

John.



More information about the llvm-commits mailing list