C++ Logo

liaison

Advanced search

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

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sun, 8 Oct 2023 16:49:40 +0300
On Fri, 6 Oct 2023 at 20:14, Timur Doumler via Liaison
<liaison_at_[hidden]> wrote:
>
> Hi Martin,
>
> Since backwards-compatibility with older compilers isn't achievable in this case (every compiler I know of will reject the colon in the attribute-like P2935 syntax as a syntax error), and the best thing you can get is backwards-compatibility with older C standards on a new compiler that already knows about Contracts and implements the "colon tweak" that was mentioned earlier, do you still think that this limited kind of backwards-compatibility is valuable enough to design the syntax around that?

There's a rather simple solution to this problem, though: don't use
the colon, rename 'assert' to something else like 'contract_assert' in
contract
annotations, and make contract annotations really be attributes.

Received on 2023-10-08 13:49:55