10

The domain and terminology

Just so we're all on the same page when it comes to the terminology, I'll summarize it. A constructor in C++ can have an optional ctor-initializer which is a grammatical rule that expands to:

: mem-initializer-list

For example:

struct S {
    int x;
    S() : x() {} // ": x()" is the ctor-initializer, and
                 // "x()" is the mem-initializer-list
};

This construct isn't formally given a name in the C++ standard, but the most accepted name for it is "member initializer list" which closely follows the name of the grammatical rule. See the cppreference article Constructors and member initializer lists. Some people also refer to it as "initialization list". CppCoreGuidelines contains both "member initializer list" and "initialization list".

There is also the fairly ambiguous name "initializer list" which may refer to one of three things:

  1. the mem-initializer-list grammatical rule
  2. the standard library class std::initializer_list
  3. the initializer-list grammatical rule, as in list initialization like std::pair{1, 2}

The tagging situation

Tag Questions Summary
78 Unambiguous tag, but rarely used because intuitively, people think of this construct as "member initializer list" or "member initialization list". Some people may also call it "constructor initializer list", which is a misnomer because a constructor only has one initializer, but multiple member initializers.
N/A Synonym for . This synonym somewhat mitigates the problem with the first tag.
127 Closely related to , and most questions with this tag should probably be tagged too. However, this is only the case for 4 questions. It looks like this tag is a sink that misleads people into thinking that there is no tag for the member initializer list.
1,207 This tag is used for all three of the above meanings of "initializer list", despite the excerpt clearly saying that it refers to std::initializer_list only.
53 Unambiguously refers to std::initializer_list. Pending synonym suggestion.
337 Unambiguously refers to list initialization, and is thus a better tag than . However, it is not as commonly used. It has 36 questions in common with the latter.

The problem in summary

The tag is ambiguous and commonly misused. is very rarely used because of its obscure name, and does not fully solve the problem because many people understand the construct as "member initializer list". is almost a synonym for , based on its usage, but actually making it a synonym would not be appropriate because it isn't equivalent.

I believe that the tagging situation is quite chaotic and confusing, with tags not being used enough or being frequently misused. What would be a good solution to the current situation?

1 Answer 1

6

The solution to member initialization

The tag refers to a general concept and should be left untouched. However, it would be beneficial if knowledgeable C++ users (silver or gold badge) tagged the ~100 questions that are eligible with a more meaningful tag such as .

is an obscure name that only makes sense to people who know C++ grammar in and out. It should be renamed to , which closely matches the mem-initializer-list rule, and is the name used by cppreference.

The solution to

This tag is cursed. As long as it exists with this name, people will misuse it to refer to:

  1. member initializer lists
  2. std::initializer_list
  3. the initializer-list rule in the grammar

Either this tag needs to be renamed to std-initializer-list (which matches the excerpt) to disambiguate, or it should be burninated for being inherently ambiguous.

If it was renamed and not burninated, there would have to be a substantial community effort to re-tag falsely tagged questions with or .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .