Open tkoeppe opened 2 years ago
It seems a bit of a stretch to apply this editorially.
Also, this touches shared territory with C, so @ThePhD might want to offer an opinion as C project editor.
Introducing this as a grammar token is likely to make life a lot easier and I would probably introduce this change in coordination with __VA_OPT__
getting into C23!
@gustedt: I think you had some views on this matter? It might be useful to gather early feedback on this!
Did C23 adopt this reformulation? Is this something we should consider for C++26?
WG14 N3095 has a "pp-balanced-token-sequence" for a pp-parameter-clause.
Just a note from a discussion with Richard, for future consideration. We have a few places in which we spell out in prose how to form a balanced preprocessor token sequence. This could be simplified if we defined a new piece of grammar. The idea, as described by @zygoloid, might look like this:
Then:
""" delete [cpp.replace.general]p5 (it's misplaced anyway; this belongs in p12). I n p12, delete "Each subsequent [...rest of paragraph 12 and paragraph 13...]".
Add new paragraph after p12, combining parts of p5, p12, p13:
"Each instance of a function-like macro name followed by a ( as the next preprocessing token shall be a function-like macro invocation of the form:
Within the sequence of preprocessing tokens making up an invocation of a function-like macro, new-line is considered a normal whitespace character. The arguments of the macro invocation are the sequences of pp-balanced-tokens separated by comma preprocessing tokens. If the identifier-list in the macro definition does not end with an ellipsis, the number of arguments (including those arguments consisting of no pp-balanced-tokens) shall equal the number of parameters in the macro definition. Otherwise, there shall be at least as many arguments in the invocation as there are parameters in the macro definition (excluding the ...). If there are sequences of preprocessing tokens within the list of arguments that would otherwise act as preprocessing directives,[Footnote] the behavior is undefined."
Then include p15 ("If there is a ... immediately preceding the )").
Then a new paragraph defining the semantics:
"Each function-like macro invocation is replaced by the replacement list in the macro definition, after performing argument substitution as described in [cpp.subst]."
Then finally p14 (the example).
I might also want to split out an "object-like macro" and a "function-like macro" section from [cpp.replace.general] """