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
Conversation
I'm not sure this is any clearer than before. THe linked issue suggests "or"; would that work? Or otherwise a larger rewrite perhaps? |
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. |
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."? |
Sounds good. Please check the force-pushed diff. |
source/classes.tex
Outdated
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}. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sounds better. Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good, thank you!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Where its definition is reachable
&&in its complete-class contexts
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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".
@jensmaurer Do you still want that trip through CWG, or is this ready to be merged? |
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. |
CWG telecon 2023-03-30: Approved. |
Fixes cplusplus/CWG#229