C++ Logo

liaison

Advanced search

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

From: Timur Doumler <cpp_at_[hidden]>
Date: Sat, 7 Oct 2023 17:31:45 +0300
> On 7 Oct 2023, at 17:29, Ville Voutilainen <ville.voutilainen_at_[hidden]> wrote:
>
> On Sat, 7 Oct 2023 at 17:21, Timur Doumler <cpp_at_[hidden]> wrote:
>
>> Yes. If you want this "function-like macro syntax" as the primary standard contracts syntax for C++, then someone (not me :) would have to actually write a paper, formally proposing that.
>
> P2961 is already such a syntax, for the near-term scope of it. The
> ostensible extensions of it aren't, but that may change if we choose
> to keep
> the feedback given here in mind.
>
>> But even if someone wrote such a paper, and even if we waive the deadlines on submitting new Contracts syntax proposals that we have set
>
> We don't need to waive any deadlines, there's nothing in P2961's
> content for C++26 that is macro-unfriendly. Everything in it is
> "pre/post(something)",
> there are no prefix-brackets or any "pre<magic>/post<magic>" bits in
> it, just possibly in its future extensions. And those extensions
> aren't set in stone, and can change.

Wait, not quite:, there is the syntax for return values in postconditions which is not a future extension – that's being proposed now:

int f()
  post (ret: ret >= 0);

Is that colon in there compatible with function-like macros? Because that's not valid function call syntax at least.

Cheers,
Timur

Received on 2023-10-07 14:31:48