C++ Logo

liaison

Advanced search

Re: [wg14/wg21 liaison] P2961R1 syntax for Contracts: viable for C?

From: Timur Doumler <cpp_at_[hidden]>
Date: Fri, 6 Oct 2023 17:06:34 +0300
> On 6 Oct 2023, at 16:35, Timur Doumler <cpp_at_[hidden]> wrote:
> So it would be very helpful to have some kind of SG22 poll or decision or record of consensus (or however you do these things!) to say one of three things: "SG22 wants the attribute-like syntax" or "SG22 wants the P296 syntax" or "SG22 is officially undecided".

Sorry, there's a typo: "P296 syntax" -> "P2961 syntax"

One more thing I would like to add is that if anyone is curious about the detailed rationale *why* we do not want to allow token-ignoring contracts in C++, there is Joshua Berne's excellent paper P2932R1 <https://wg21.link/p2932r1> which explains this in section 2.2. The key quote is this one:

Principle 2: Program Semantics Are Independent of Chosen CCA Semantics
The semantic with which a CCA is evaluated must not affect the compile-time semantics surrounding that annotation, e.g., any observable traits of expressions or function invocations involving evaluation of the CCA.

("CCA" stands for "contract-checking annotation"; "semantic" means one of the following three: "ignore" (don't evaluate predicate), "observe" (evaluate predicate; if it does not evaluate to `true`, print a diagnostic and continue), and "enforce" (evaluate predicate; if it does not evaluate to `true`, print a diagnostic and terminate the program).

Cheers,
Timur

Received on 2023-10-06 14:06:39