[cfe-dev] draft rule for naming types/functions/variables
Zhanyong Wan (λx.x x)
wan at google.com
Tue Nov 23 10:19:21 PST 2010
On Tue, Nov 23, 2010 at 10:12 AM, Bo Persson <bop at gmb.dk> wrote:
> 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?
These are not allowed because they are not in camel case:
http://en.wikipedia.org/wiki/CamelCase
>
>
> Bo Persson
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
--
Zhanyong
More information about the cfe-dev
mailing list