C++ Logo


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:21:32 +0300
> On 7 Oct 2023, at 17:13, Ville Voutilainen <ville.voutilainen_at_[hidden]> wrote:
>> But yes, I get your point, you could still have a syntax that looks like a function-type macro so while you can't replicate the behaviour without the new language feature, you can at least macro it out and avoid syntax errors, without the need to surround the contracts with #ifdefs. That's the idea here, right?
> Right. But I don't think that's worth anything for C++ programmers.
> It's doubtful we'd want to suggest that they polyfill a language
> facility
> with lowercase macros; for all intents and purposes, it's better just
> to tell them to #ifdef things out with the help of feature-detection
> macros, and macro the whole contract annotation with a "normal"
> uppercase macro. So, while being macro-friendly to such polyfills
> may be better for our WG14 friends here, I can easily see some WG21
> members balking at the idea with a "that's not a technique
> that we want to encourage".

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. 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, --- given the results of the electronic poll we did in P2885 <https://isocpp.org/files/papers/P2885R3.pdf>, which revealed among other things that macro-friendliness and backwards-compatibility with older compilers are non-goals for C++ Contracts, realistically I don't see that paper going anywhere particularly far in C++ land.


Received on 2023-10-07 14:21:36