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

[class.mem.general] Clarify ambiguous 'and' #6060

Merged
merged 1 commit into from Aug 14, 2023
Merged

Conversation

jensmaurer
Copy link
Member

@tkoeppe
Copy link
Contributor

tkoeppe commented Jan 24, 2023

I'm not sure this is any clearer than before. THe linked issue suggests "or"; would that work? Or otherwise a larger rewrite perhaps?

@jensmaurer
Copy link
Member Author

Mike Miller says "or" doesn't read well, and he suggested (among other options such as "and also" and "in addition to") the words chosen here. I think "as well as" is less suggestive of and-connected conditions.

@tkoeppe
Copy link
Contributor

tkoeppe commented Jan 24, 2023

But it still admits the same erroneous interpretation as the original wording, doesn't it?

How about: "A class is regarded as complete with its complete-class contexts and also wherever its definition is reachable."?

@jensmaurer
Copy link
Member Author

Sounds good. Please check the force-pushed diff.

where its definition is reachable and
within its complete-class contexts;
within its complete-class contexts and also
wherever its definition is reachable;
otherwise it is regarded as incomplete within its own class
\grammarterm{member-specification}.
Copy link
Member

@zygoloid zygoloid Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little strange for the "otherwise" case to not cover all cases not covered by the previous rule. This reordering makes it stranger by moving the complete-class context part away from the other member-secification pieces.

How about something like:

A class is complete where its definition is reachable, and in complete-class contexts within its member-specification. Otherwise it is incomplete, including in other parts of its member-specification.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sounds better. Updated.

@tkoeppe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good, thank you!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a constructive rule is better:

A class is complete:

  • at the point where its definition is reachable, or
  • in complete-class contexts within its member-specification

Otherwise it is incomplete, including in other parts of its member-specification.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think that's better than the previous suggestion? The sentence seems short enough to not require a list, and also I don't think the "or" is right: a class is really complete in both cases, not just in "at least one of these cases". "Or" would be appropriate if we said, "In order to be complete, a class has to [either X] or [Y]", but as written, "and" seems more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mike M. says that "complete-class context" is already applying to "within its member-specification" per the definition, so the extra normative mention of "within its member-specification" is superfluous.

However, this is now deviating from the existing words quite a bit, so I'm wondering whether we want a brief trip through CWG.

Copy link
Contributor

@xmh0511 xmh0511 Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "within the member-specification" should be removed in both "otherwise case" and "complete-class contexts". We have completely defined what complete-class context is:

A complete-class context of a class (template) is a

  • [...]

within the member-specification of the class or class template.

This implies, e.g., that the function body of the member function outside of the member-specification is not a complete-class context. Conversely, when we refer to "complete-class context", we are saying the contexts defined in the list that appears in the member-specification of the class. Hence

A class is considered to be complete either:

  • at the point where its definition is reachable, or
  • in its complete-class contexts

Otherwise, it is incomplete.

This is clear, I think.


For and in the updated wording, I still think "and" can result in ambiguity. How should we parse that wording?

A class is complete

  1. Where its definition is reachable && in its complete-class contexts
  2. Where its definition is reachable || in its complete-class contexts

Case 1 is not the intent but it can embody what and here means. Obviously, the class is considered to be complete if merely one of the conditions is achieved. So, constructive wording is appreciated here to avoid ambiguity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a class is really complete in both cases, not just in "at least one of these cases". "Or" would be appropriate if we said, "In order to be complete, a class has to [either X] or [Y]", but as written, "and" seems more appropriate.

For and in the updated wording, I still think "and" can result in ambiguity. How should we parse that wording?

Mind you, the current wording uses "and also", which is correct.

Copy link
Contributor

@xmh0511 xmh0511 Jan 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does "and also" appear in the current wording? The current wording is just ambiguous due to its "and".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I was looking at the diff of this PR, which added "also".

@tkoeppe
Copy link
Contributor

tkoeppe commented Mar 12, 2023

@jensmaurer Do you still want that trip through CWG, or is this ready to be merged?

@jensmaurer
Copy link
Member Author

This needs more massaging, in particular "within its \grammarterm{member-specification}" is redundant with the definition of "complete-class context". I feel the "otherwise" part then falls apart.

@jensmaurer
Copy link
Member Author

jensmaurer commented Mar 12, 2023

I now have a formulation that super-clearly picks up the defined terms (e.g. "reachable from P") and thus should be an improvement. We're now using "if", so "or" is appropriate, too, and the "otherwise" reads better.

@tkoeppe @zygoloid @JohelEGP opinions welcome.

I'll have CWG have a look, too.

@jensmaurer jensmaurer requested review from zygoloid, JohelEGP and tkoeppe and removed request for JohelEGP March 13, 2023 05:52
@tkoeppe tkoeppe removed their assignment Mar 19, 2023
@tkoeppe tkoeppe added the cwg Issue must be reviewed by CWG. label Mar 19, 2023
@jensmaurer
Copy link
Member Author

CWG telecon 2023-03-30: Approved.

@tkoeppe tkoeppe merged commit 1353359 into cplusplus:main Aug 14, 2023
2 checks passed
@jensmaurer jensmaurer deleted the c68 branch August 15, 2023 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[class.mem.general] p8 "and" overly impose the requirements
5 participants