Skip to content
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

[format.parse.ctx] Paragraph 14 is hard to read #6801

Closed
Eisenwave opened this issue Feb 9, 2024 · 5 comments · Fixed by #6815
Closed

[format.parse.ctx] Paragraph 14 is hard to read #6801

Eisenwave opened this issue Feb 9, 2024 · 5 comments · Fixed by #6815

Comments

@Eisenwave
Copy link
Contributor

Eisenwave commented Feb 9, 2024

Remarks: Call expressions where id >= num_args_ or the type of the corresponding format argument (after conversion to basic_format_arg<Context>) is not one of the types in Ts... are not core constant expressions ([expr.const]).

The meaning of [format.parse.ctx] p14 is completely lost on me:

  1. What does it mean to say "is not one of the types in Ts... are not ..." ? This isn't valid English.
  2. Why does this function have no Effect and no Returns paragraph? There are only Remarks, so I have no idea what it's actually meant to do.
  3. What does "call expressions" even mean? Does it mean that this function calls expressions? Is it meant to say "Calls expressions and I've just missed some expressions definition? Does it mean that calling this function is a call expression?

Granted, I know very little about the formatting library but this wording just looks like gibberish to me.

@jwakely
Copy link
Member

jwakely commented Feb 9, 2024

  1. Read it as:

Call expressions where one of the following conditions is true are not core constant expressions ([expr.const]):

  • id >= num_args_
  • or the type of the corresponding format argument (after conversion to basic_format_arg) is not one of the types in Ts...

@jwakely
Copy link
Member

jwakely commented Feb 9, 2024

  1. It has no Effects, because it has no effects. The only effect is to be a core constant expression, or not. That's so that you get an error if the conditions are not met when the consteval function checks the format string. It has no Returns because its return type is void.

@jwakely
Copy link
Member

jwakely commented Feb 9, 2024

  1. No, it doesn't mean that. It means "expressions that are calls of this function", i.e. invocations of this function.

@Eisenwave
Copy link
Contributor Author

Eisenwave commented Feb 9, 2024

  1. Read it as:

Call expressions where one of the following conditions is true are not core constant expressions ([expr.const]):

  • id >= num_args_
  • or the type of the corresponding format argument (after conversion to basic_format_arg) is not one of the types in Ts...

Yeah thanks, it took me a while. It's pretty late here and the run-on sentence just really messed with my head.

It has no Effects, because it has no effects. The only effect is to be a core constant expression, or not. That's so that you get an error if the conditions are not met when the consteval function checks the format string. It has no Returns because its return type is void.

I've read P2757R3 and it sort of makes sense, but it's quite the surprising function and I feel like this deserves a note which explains the intent at least.

No, it doesn't mean that. It means "expressions that are calls of this function", i.e. invocations of this function.

I would have much preferred the wording "Invocations of this functions" over "Call expressions". It wasn't obvious to me that the very general statement about expressions is meant to apply to calls to this particular function. Maybe that's just me, but it stumped me. I can't think of having seen "Call expressions" used in such a way anywhere else in the standard either.

@Eisenwave
Copy link
Contributor Author

Eisenwave commented Feb 9, 2024

What do you think about the following wording?

An invocation of this function is a core constant expression only if

  • id < num_args_ is true and
  • the type of the corresponding format argument (after conversion to basic_format_args<Context>) is one the types in Ts....

The old wording was unnecessarily complex in terms of grammar. This grammatical sandwiched wasn't reader-friendly and I'm sure I'm not the last person to be stumped by it.

Furthermore, the negation was counter-productive. It defined that it's "note a constant expression if the type is not one of ...". Such double negations are confusing to the reader and it is much easier to express when a call is a constant expression.

I guess a note would also be nice, along the lines of:

This function has no effect. It is meant to verify during constant evaluation whether an argument typematches one of T....

@Eisenwave Eisenwave changed the title [format.parse.ctx] Paragraph 14 is gibberish [format.parse.ctx] Paragraph 14 is hard to read Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants