2

TL;DR

Suppose that a question asks about the rationale of including a specific feature in a language (C++, if that matters). Is it appropriate to tag this question ?

Full story

Here's the full body of the Stack Overflow question Example of class object implementing operator[] using an initializer-list as the function argument:

[expr.sub]/4 allows an initializer-list to be passed as an argument of operator[] for an object of class type. What would be a practical example using this technique?

which is tagged by the OP.

@StoryTeller removed the tag with the edit summary

This is not a language lawyer question. Practical examples are not about the intricacies of the specification.

However, this edit is rolled back by the OP, without providing a reason.

Later, I removed the tag again, leaving the comment

Why do you tag language-lawyer? I don't think the answer to this question can be found in the standard.

The OP rolled back again, this time providing a comment:

@L.F. If I can't find an example for this use, I'll have a strong indication that the grammar production [...] could be simplified. With this in mind, I'm rolling back your edit.

followed by two other comments:

I'm sorry, but the standard allowing one thing doesn't necessarily mean you can easily find a practical example of its usage. The fact that the standard allows something isn't inherently language lawyering. I believe your actual question is "what is the rationale for allowing a braced-init-list in []", which isn't a language-lawyer question. If not, then you should clarify your question. – L. F.

@L.F. Well,I disagree with your statement above: "what is the rationale for allowing a braced-init-list in []", which isn't a language-lawyer question. – Alexander

Apparently, my persuasion had little effect, so I refrained from starting an edit war. That's why I am asking here on Meta.

The tag info

From the tag info:

For questions about the intricacies of formal or authoritative specifications of programming languages and environments.

Typical questions concern gaps between "what will usually work in practice" and "what the spec actually guarantees", but problems with understanding the structure of the spec are also on topic.

Use this tag for questions where you are interested in the formal specification for a certain behavior in the given programming language, even though your question might otherwise have no practical use, or if the code posted would not make sense in a real-world application.

Always combine this tag with a programming language tag.

I'm not sure whether this particular question is about the "intricacies of formal or authoritative specifications of programming languages and environments" or is "interested in the formal specification for a certain behavior in the given programming language." StoryTeller and I don't think so, but I would like to hear the opinion of the community.

2

1 Answer 1

5

Asking about rationales for why a program language is designed in a certain way isn't necessarily answerable. These can be good questions but most of the time not... simply because C and C++ were far from rationally designed. Questions asking for rationales or practical use of certain C or C++ language features depressively often boil down to "what were they smoking when they came up with this feature?"

should be used when you expect someone to dig through the formal standard in order to provide an answer, or when you are asking a question that doesn't necessarily have any practical use.

As for this specific question, I think you'd need to be quite the language lawyer to explain it. Among C++ language lawyers it is well-known that since E1[E2] is equivalent to *((E1)+(E2)), then E2 could as well be the array operand, since E1 + E2 is equal to E2 + E1.

So E2 could in turn be an initializer list/anonymous array/compound literal... C++ has apparently been allowing various forms through the years.

I don't know the full story from pre-standard to C++2x, nor do I know about some crazy story about the "deprecated comma in subscript operator"... because I'm not enough of a C++ language lawyer to answer that.

So it seems perfectly reasonable to use for this question. This isn't something that the average C++ programmer can answer, or would be interested in reading/answering. Nor do/should they care why crap code such as 0[(int){1,2,3}] will compile cleanly.

0

You must log in to answer this question.

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