[LLVMdev] [cfe-dev] draft rule for naming types/functions/variables

Bo Persson bop at gmb.dk
Tue Nov 23 10:12:47 PST 2010


Zhanyong Wan (λx.x x) wrote:

> If possible, I'd prefer that all variable names have the same style.
> I'm afraid that we'll end up with the current inconsistent style if
> we
> leave it to people to interpret whether a name is metasyntactic and
> thus should be lower-case.
>
> Also, having both types and variables in StrictCamelCase increases
> the
> chance of clashing between the two and thus sometimes makes it hard
> to
> choose good variable names.  For example, if you have a function
> that
> takes a Type parameter, how would you name the parameter if it has
> to
> start with an upper-case?  There are several obvious choices:
>
>  void VisitType(Type T);  // Bad -- T is too generic and could be
> mistaken for "temporary".
>  void VisitType(Type Ty);  // Bad -- Ty is not a well-known
>  abbreviation. void VisitType(Type AType);  // Unnecessarily
> awkward.
>
> In contrast,
>
>  void VisitType(Type type);
>
> is readable and natural.  The same argument applies to other kinds
> of variables.
>

I don't think this is natural at all.  :-)

When the rule is to select readable and descriptive names, using names 
that only differ in case seems non-optimal. What about tYpe, tyPe, or 
typE?


Bo Persson




More information about the llvm-dev mailing list