[LLVMdev] RFC: variable names

Chris Lattner clattner at apple.com
Tue Oct 14 14:55:53 PDT 2014

On Oct 13, 2014, at 4:31 PM, Chandler Carruth <chandlerc at google.com> wrote:

> On Mon, Oct 13, 2014 at 4:14 PM, Chandler Carruth <chandlerc at google.com> wrote:
> 1. Initialisms. It's common in Clang code (also in LLVM?) to use initialisms as variable names. This doesn't really seem to work for names that start with a lower case letter.
> I think wee at least need a good answer to this.
> As I really suspect this is the most important point to address, let me make an attempt:
> Variable names are *either* initialisms, written as all caps, or terms written in lower case and separated by underscores. For the purposes of variable naming "terms" can include words but also extremely common and recognizable abbreviations within LLVM such as "rhs", "lhs", or "gep". These types of terms should not be written as initialisms but as words. For example, you might write "LE" or "lhs_expr" for the Left-hand Expression, but not "LHSE" or "LHS_expr".
> While I'm trying to avoid it, this has the advantage of leaving a large number of initialisms in the existing code base as "stylish".
> I'm not really happy with this rule, but it is the least disruptive and most consistent I can come up with. I would also be happy encouraging people to not use initialisms excessively or if confusing. I think the current codebase uses them more than is helpful.

Personally, I’d prefer “initialism” or “lower camel case”.  I’m not sure what the problem with lower camel case was?  I don’t see how lambdas are confusing here.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141014/04a2929a/attachment.html>

More information about the llvm-dev mailing list