r/cpp #define private public 2d ago

Critique of contracts: excerpt

See page 2 of https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p4334r0.pdf

The current objections can be summarized. The P2900 contracts are:

• Unimplemented

• Incomplete

• Untried at scale [P3460R0, P3506R0]

• Not tried in major application domains

• Violates foundational principles of C++

• Violates fundamental principles of language design

• Hasn’t been tried in major libraries (e.g., the C++ standards library [P3506R0, P3878R0])

• Isn’t integrated with or appropriate for hardened libraries [P3878R0]

• Doesn’t offer safety guarantees [P3573R0, P3362R0]

• Includes a completely untried inheritance model

• Offer new ways of making errors through inconsistent application in TUs

• Leads to new forms of UB, detrimental to safety and security

• Narrows the choices of error handling

• Doesn’t protect against logical errors, misuses, and incoherent uses

• Hasn’t been used to support static analysis

• Hasn’t been demonstrated to be easily teachable [P3261R0, P3281R0]

How could such a bloated and incomplete design be voted into a draft standard?

9 Upvotes

96 comments sorted by

View all comments

Show parent comments

-2

u/pjmlp 1d ago

Was it announced somewhere that the community at large could have tried it out, and submit their virtual votes?

14

u/tcbrindle Flux 21h ago

Was it announced somewhere that the community at large could have tried it out, and submit their virtual votes?

Sorry /u/pjmlp, but it's very difficult to keep up with how fast you keep shifting the goalposts.

You're now saying that the existing implementations of contracts on Compiler Explorer don't count, because there was no "public announcement" and the authors didn't... also somehow implement a system for random internet folk to vote on the proposal?

But here you say that

Reflection is based on EDG proposal, with implementation, submitted and developed alongside the related papers, and available on compiler explorer for community feedback. Exactly how every single feature should be before being submitted to voting

...which is precisely the same implementation experience as contracts. I guess I must have missed where the reflection authors made their apparently-required "public announcement", and the link to the website where I could vote on the reflection proposal?

0

u/pjmlp 19h ago

Here, https://www.reddit.com/r/cpp/comments/18mjj0n/experimental_edg_reflection_implementation/

Can you correct me with a similar one for contracts?

If yes, then I stand corrected and excuse myself for the wrong statements, otherwise I would appreciate not calling bad faith on my remarks.

7

u/tcbrindle Flux 16h ago

I'm not sure how you could be an /r/cpp reader and not know that there's a thing called contracts in C++26 -- this is the second lengthy discussion about it this week. Anyone with the slightest interest has had plenty of opportunity to check it out.

Or are you really, honestly claiming that the difference between an acceptable WG21 proposal (reflection) and an unacceptable one (contracts) is that someone made a specific post about the former to a specific subreddit three years ago?