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

[2025-02 CWG Motion 5] P2900R14 - Contracts for C++ #7695

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

notadragon
Copy link
Contributor

@notadragon notadragon commented Feb 18, 2025

Fixes: #7655
Also Fixes: cplusplus/papers#1648

I have put comments in starting with JMB (my initials) where an editorial change was made due to minor mistakes in P2900 (missing comma, rebasing, etc.) as well as some places where I think we should have additional xrefs.

This is also based on the changes for P1494 (#7681) as we modify a paragraph added there. That should certainly merge first, and I will keep this PR rebased on it.

@tkoeppe tkoeppe force-pushed the motions-2025-02-cwg-5 branch from 10cb85c to a470da8 Compare February 24, 2025 15:03
@@ -2283,7 +2297,7 @@
\begin{bnf}
\nontermdef{init-declarator}\br
declarator \opt{initializer}\br
Copy link
Contributor

Choose a reason for hiding this comment

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

\opt needs to be removed here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch, i totally missed that edit. Done.

source/intro.tex Outdated
@@ -788,10 +795,14 @@
\begin{itemize}
\item
a preprocessing translation unit containing
a \tcode{\#error} preprocessing directive\iref{cpp.error} or
a \tcode{\#error} preprocessing directive\iref{cpp.error}, %JMB: this last comma was a mistake in P2900, it was not in green.
Copy link
Member

Choose a reason for hiding this comment

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

In general, fixing commas and such can be done on-the-fly without much ado.

Please remove the "JMB" comment; we don't want that in the merged .tex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I just wanted to make sure additional eyes saw any deviations that occured relative to P2900's cwg-reviewed text. (And also yes, we shouldn't merge this until all of the JMB comments have been looked at and removed).

source/intro.tex Outdated
Comment on lines 942 to 948
\pnum
\indextext{observable checkpoint}
Certain events in the execution of a program
are termed \defnadj{observable}{checkpoints}.
\begin{note}
A call to \tcode{std::observable}\iref{utility.undefined}
is an observable checkpoint,
Copy link
Member

Choose a reason for hiding this comment

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

This is duplicate with the preceding paragraph. Somehow, this needs to be rebased properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

boo on git. fixing.

source/basic.tex Outdated
@@ -544,9 +551,10 @@
between the point at which the entity is introduced and the scope
(where \tcode{*\keyword{this}} is considered to be introduced
within the innermost enclosing class or non-lambda function definition scope),
either:
either: %JMB: Potential drive-by, we should remove the : and the first two "or"s.
Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with applying the drive-by.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

source/basic.tex Outdated
in the body of the called function.
the postfix expression designating \placeholder{f}
are sequenced before
every precondition assertion of \placeholder{f}\iref{dcl.contract.func}, %JMB: This said "of the called function", changed to "of f"
Copy link
Member

Choose a reason for hiding this comment

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

Ack, looks good, remove "JMB".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

source/basic.tex Outdated
every expression or statement
in the body of \placeholder{f},
which in turn are sequenced before
every postcondition assertion of \placeholder{f}. %JMB: This says "the called function" again in P2900
Copy link
Member

Choose a reason for hiding this comment

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

Ack, looks good, remove "JMB"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

source/basic.tex Outdated
of the predicate of a contract assertion,
no diagnostic required.

%JMB: This paragraph was not in P2900, but the note is not directly tied to the paragraph above.
Copy link
Member

Choose a reason for hiding this comment

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

Ack, that's fine, remove JMB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

source/basic.tex Outdated
Comment on lines 7380 to 7381
are const\iref{expr.prim.id.unqual}, %JMB: P2900 had this const in code font
\tcode{this} is a pointer to const\iref{expr.prim.this}, %JMB: P2900 had this const in code font
Copy link
Member

Choose a reason for hiding this comment

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

This is a note. I agree non-code-font is slightly better (more casual, in a casual sentence). Remove JMBs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -3606,7 +3559,7 @@
in~\ref{global.functions}, member functions in~\ref{member.functions}, data race
avoidance in~\ref{res.on.data.races}, access specifiers
in~\ref{protection.within.classes}, class derivation in~\ref{derivation}, and
exceptions in~\ref{res.on.exception.handling}.
exceptions in~\ref{res.on.exception.handling}. %JMB: This intro fluff should add "and contract assertions in~\ref{res.contract.assertions} Also, the "its use" doesn't seem right in this sentence. Can I make this a bulleted list so that it resembles a sentence again?
Copy link
Member

Choose a reason for hiding this comment

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

Please drop the JMB in a fix-up commit to the original one (will be squashed).
Then, add a separate commit (same pull request) with proper "[label] title" commit description that improves this (yes, a bulleted list seems great). Do not silently improve this in the original paper-applying commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

\item
otherwise,
the implied object argument is
\tcode{(*\keyword{this})}. %JMB: The \keyword on this was missing
Copy link
Member

Choose a reason for hiding this comment

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

Ack, trivially obvious fix, remove JMB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

by those \grammarterm{assertion-statement}s.
\begin{note}
A sequence of \grammarterm{assertion-statement}s
can thus be repeatedly evaluated as a group. %JMB: Should we remove the "thus"?
Copy link
Member

Choose a reason for hiding this comment

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

It's in the paper, it's in a note, and it's a consequence from the "evaluated in sequence" normative text. Leave it in; remove JMB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@notadragon notadragon force-pushed the motions-2025-02-cwg-5 branch from 37d5acb to f9fac8b Compare February 24, 2025 22:13
Each successive temporary object
is initialized from the previous one
as if by direct initialization if \tcode{X} is a scalar type,
otherwise by using an eligible trivial constructor.
Copy link
Contributor

Choose a reason for hiding this comment

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

“direct initialization” should be “direct-initialization”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

The function parameter or return object is initialized
from the final temporary
as if by direct initialization if \tcode{X} is a scalar type,
otherwise by using an eligible trivial constructor.
Copy link
Contributor

Choose a reason for hiding this comment

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

“direct initialization” should be “direct-initialization”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

notadragon and others added 2 commits February 27, 2025 21:56
…e because that seems to be the consistent style in the standard, removed informational-only JMB comments
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 this pull request may close these issues.

[2025-02 CWG Motion 5] P2900R14 Contracts for C++ P2900 R13 Contracts for C++
7 participants