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. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141013/b5984d26/attachment.html>
> 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 <mailto: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.This makes sense to me. I think it strikes a good balance between updating our conventions to be better and also reflecting common in-practice usage patterns.> FWIW, I think that having different naming conventions for data members and local variables has become essentially untenable with lambdas and capture.Can you elaborate a bit more on this? Maybe an example or two. I’m very supportive of the general direction of all of this. Glad to see the general consensus developing. -Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141013/dabaa153/attachment.html>
On Mon, Oct 13, 2014 at 5:09 PM, Jim Grosbach <grosbach at apple.com> wrote:> FWIW, I think that having different naming conventions for data members > and local variables has become essentially untenable with lambdas and > capture. > > > Can you elaborate a bit more on this? Maybe an example or two. > > I’m very supportive of the general direction of all of this. Glad to see > the general consensus developing. >See my reply to David, I think it highlights the horrors here. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141013/51a2cd3a/attachment.html>
On Mon, Oct 13, 2014 at 5:09 PM, Jim Grosbach <grosbach at apple.com> wrote:> > 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. > > > This makes sense to me. I think it strikes a good balance between updating > our conventions to be better and also reflecting common in-practice usage > patterns. >This convention sounds like it would cause people to have to be constantly asking themselves "is this common enough to be an initialism-as-word or not?". The thing that started this conversation was someone complaining about going between codebases that they weren't sure whether to capitalize; now that person will have to get a feel for the local initialism-as-word's, which is a much greater burden than just the naming convention. -- Sean Silva> > FWIW, I think that having different naming conventions for data members > and local variables has become essentially untenable with lambdas and > capture. > > > Can you elaborate a bit more on this? Maybe an example or two. > > I’m very supportive of the general direction of all of this. Glad to see > the general consensus developing. > > -Jim > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141013/bb26aa28/attachment.html>
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”.Seems like you are jumping ahead to “minimize transition costs” instead of thinking about what the end result should be.> > 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.I’ve never been one to use initialisms. But, is there some reason they cannot be all lowercase (e.g. “NamedDecl *nd”)? -Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141013/f00af726/attachment.html>
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. -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141014/04a2929a/attachment.html>
After having read through this long thread, I'm having trouble spotting a case of someone saying lowerCamelCase variable names is a bad idea. Nick's original proposal looks good to me. What do we need to do to move forward here? Thanks, Greg On Tue, Oct 14, 2014 at 2:55 PM, Chris Lattner <clattner at apple.com> wrote:> > 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. > > -Chris > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >