<div dir="ltr"><div dir="ltr">On Fri, Feb 22, 2019 at 5:59 AM via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">- Local variables and formal parameters should be lower_case, with<br>
  one exception: Variables/parameters that have lambda/function<br>
  type should follow the function-name spelling rules.<br></blockquote><div><br></div><div>I really dislike this exception. Callable objects are *objects* and locally scoped, I would much prefer they look like variables.</div><div><br></div><div>Also, what about callable objects that aren't lambdas? Or that use operator() for something other than emulating a function call?</div><div><br></div><div>I think the simple rule is superior. </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">- Initialisms and other abbreviations would be considered words for <br>
  this purpose, so we have names such as:<br>
    tli   // Local variable for TargetLoweringInfo<br>
    m_cgm // Data member for CodeGenModule<br></blockquote><div> </div><div>Agreed.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
- I don't have a good suggestion for file-static/global variables.<br>
  Some people have suggested a "g_" prefix for globals, or possibly<br>
  an "s_" prefix for class-static data.<br></blockquote><div><br></div><div>These are rare enough that I'm not sure we need special rules for naming them. They should also should typically be wrapped up in an actual API limiting how widely they are referenced.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Regarding the transition:<br>
<br>
Some people have worried that the churn will cause blame issues.<br>
I respectfully point out that in my own archaeology I have to deal<br>
with lots of clang-format/indentation/other random semantically<br>
meaningless refactoring, this is just one more.  Also the point is<br>
not to optimize for git-blame but to optimize for reading what is<br>
there at the moment.<br>
<br>
A more focused and shorter transition period will create a lot of<br>
short-term churn but get us to the good endpoint sooner.  Doing<br>
conversions per-file or per-class (rather than per-function [too<br>
small] or per-library [too big]) are probably the way to go.  <br>
Given we are changing the names used for _data_, and we try to <br>
practice good data-hiding, the impact of the conversion of any <br>
given class *ought* to be reasonably confined.<br></blockquote><div><br></div><div>I generally agree with this strategy. That said, I would still do it somewhat lazily rather than eagerly, but batched much as you're suggesting.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
If someone can make clang-tidy help with this, that's awesome.<br>
<br>
I'm almost afraid to make the next suggestion, but here goes:<br>
In more complicated/wide-impact cases, it would be possible to<br>
stage a data-member name conversion into "small-bang" iterations<br>
using a C++ tactic like this:<br>
    class Foo {<br>
      int m_bar; // The renamed member.<br>
      int &Bar = m_bar; // TEMPORARY alias using the old name.<br>
    };<br>
This would have to be done sparingly and for good reason, such as<br>
when the names are known across many components/subprojects and <br>
doing them all at once would be really too much. Someone would<br>
have to commit to getting it all done and removing the aliases in<br>
a reasonably short period of time.  Needing to do this trick would<br>
be (IMO) strong evidence of poor software design and a place to<br>
focus some refactoring effort.<br></blockquote><div><br></div><div>Honestly, I don't think we need to do this. We routinely make wide-ranging API updates. If we need to do that, we do that.</div><div><br></div><div>What we *should* do is encourage anyone that before they decide to do this to discuss it and see if there is a good way to hide this usage of a variable name behind a better API and make *that* widespread change instead. Then the name change is more local again.</div></div></div>