C++ Logo

liaison

Advanced search

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

From: Robert Seacord <rcseacord_at_[hidden]>
Date: Thu, 5 Oct 2023 08:26:57 -0400
We could discuss this here, because it's not the full WG14 membership. We
also have a mailing list set up to discuss Future C that also does not
include the full membership. You can probably find people smarter than me
in either place.

Thanks,
rCs

On Thu, Oct 5, 2023 at 7:58 AM Timur Doumler via Liaison <
liaison_at_[hidden]> wrote:

> Hello SG22,
>
> In SG21 (Contracts), we have been discussing the syntax for preconditions,
> postconditions, and assertions which will be part of the new Contracts
> facility we're designing for C++26. We currently have two syntax proposals
> on the table – we have not yet decided which one we prefer.
>
> One is the attribute-like syntax which you might have already seen (see
> P2935R3 <https://wg21.link/p2935r3>). With this syntax, a function
> declaration with a precondition and a postcondition looks like this:
>
> int f(int i)
> [[ pre: i >= 0 ]]
> [[ post r: r > i ]];
>
> The other is a newer proposal that seeks to eliminate the various issues
> with attribute-like syntax we discovered (see P2961R1
> <https://wg21.link/p2961r1>, which I am co-authoring together with Jens
> Maurer, in Cc). The P2961R1 syntax looks like this:
>
> void f(int i)
> pre (i >= 0)
> post (r: r > i);
>
> At the last SG21 telecon, the question has been raised whether the P2961R1
> syntax would be compatible with C, in case C wishes to standardise a
> Contracts facility consistent with the C++ one. As the main paper author of
> P2961R1, I was directed to ask WG14 about their opinion and report back to
> SG21.
>
> However, I have been informed by Ville (in Cc) that WG14 is currently
> doing a ballot, that the WG14 Convener is adamant about having as little as
> possible technical discussion during a ballot, and that discussing a
> future proposal on the WG14 reflector would therefore be inappropriate at
> this time.
>
> So, if you don't mind, I'm going to try my luck with SG22 instead. Do any
> of you folks have any desire to standardise Contracts for C, to have a
> syntax for this that looks like the C++ one, and do you have any technical
> concerns about the syntax proposed in P2961R1 <https://wg21.link/p2961r1>?
>
> Any and all feedback would be greatly appreciated.
>
> Thanks,
> Timur
> _______________________________________________
> Liaison mailing list
> Liaison_at_[hidden]
> Subscription: https://lists.isocpp.org/mailman/listinfo.cgi/liaison
> Searchable archives: http://lists.isocpp.org/liaison/2023/10/index.php
>

Received on 2023-10-05 12:27:11