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

Zhanyong Wan (λx.x x)
Mon, 29 Nov 2010 19:07:36 -0000

On Sun, Nov 28, 2010 at 11:02 PM, Anton Korobeynikov
<anton at korobeynikov.info> wrote:
>> I enjoyed the new coding style in recent patches. Camel case makes it
easy
>> to pick a descriptive name. Starting functions and variables with lower
>> cases reduces chances to conflict with a type name.
> Honestly speaking, I don't. Especially in the cases when varname is
> made from an
> acronym. E.g. MachineInstr *MI looks much better than MachineInstr *mi,
etc.
>
> See latest Rafael's patch as an example.

I think it's worthwhile to note that:

C++ is such a complex language that no single naming convention will
be able to cover all cases.  Therefore we aim at a reasonable default
that works for the majority of the cases.  As Chris put at the
beginning of the coding standards, "no coding standards should be
regarded as absolute requirements to be followed in all instances."
Exceptions can be made (although rarely) when truly needed.

Csaba has pointed out the problem of possible clash (at least
confusion) with macro names for variable names like MI.  I agree that
'mi' is not a great name either in this case.  In fact, it's not
even
camel case.  How about instr?  Or, perhaps a name that clarifies its
role (jumpInstr, nextInstr, etc)?  Or, if this is a short-lived local
variable, I'd be fine with 'mi'.

Cheers,
--
Zhanyong