-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1191 replace member variable with data member #2087
Conversation
The referenced discussion (#2078) doesn't seem to be much of a discussion with many commentators - it's three people, one of which asked the question and two of which (myself included) provided responses; both of which are more or less in agreement. I'm not sure the request here really clarifies much if anything. When referencing classes FWIW - my 👎 is not so much opposition to the change itself, but the reasoning behind the change as the term |
That's just your personal opinion. At the end of the day, cppreference, most StackOverflow questions, the C++ standard, most C++ books, etc. all use the term "data member". It is the correct term, whether you personally prefer it or not. Whether the guidelines should be using data member or member variable is one question, another one is: should they be using the same term consistently in the whole document? The answer is obviously yes, and this PR adds that consistency. If you dislike the use of the term data member and want it changed to member variable, why don't you just make another PR that implements that throughout the document? For now, let's just be consistent. |
Whatever decision we take, I think it is important to not use the word "variable" in the term we use to describe a non syatic data member. The term variable has already a meaning defined in the standard. Briefly, it is the name of an object or reference. But a non static data member declaration does not define an object. The distinction is important because most guidelines that would apply to objects or variables do not apply to non static data members and vice versa. In particular, regarding the use of const qualifier in the declarations: non static data members should never be declared const, but variables/objects declarations may favor the const qualifier depending on circumstances. |
The referenced discussion (#2078) suggests using non-static data member, whereas this change only renamed to data member. |
That's a separate issue and a shortcoming of the original text. You would also need to disambiguate between
but this wasn't done because people sort of assume that "data member" or "member variable" refer to non-static, unless otherwise stated. I personally think it's fine to keep it this way as well. I'd be equally fine disambiguating it everywhere. |
Editors call: Thanks! |
This PR implements #1191.
The colloquial term "member variable" is replaced with either:
It would be even less ambiguous to say "static data member" or "non-static data member", but this is very verbose and the reader can contextually understand whether non-static members are referred to.
For example, when we write:
This almost certainly doesn't refer to static data members, because it is impossible to initialize them in the constructor (unless lifetimes are managed explicitly).
While many C++ developers understand what a "member variable" is, it: