C++ Logo

liaison

Advanced search

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

From: Jens Maurer <jens.maurer_at_[hidden]>
Date: Fri, 6 Oct 2023 18:35:50 +0200
On 06/10/2023 18.32, Timur Doumler wrote:
>
>
>> On 6 Oct 2023, at 19:28, Jens Maurer <jens.maurer_at_[hidden]> wrote:
>>> If that is indeed the case, then the attribute-like syntax for Contracts would not be ignorable in C, either.
>>
>> Right, but the argument is that implementations can add the small extension
>> to parse-ignore ":" in that spot right now, and then be future-proof for
>> ignoring future attribute-like contracts.
>
> Right. Yes, I can follow that argument. But that begs the question: what is so special or different about Contracts that you want this feature in particular to be backwards-compatibly-ignorable by older compilers, considering that we don't do that for any other new language feature where we add new syntax to the language?

The argument, as far as I understand, is that contracts in particular are well
suited to be retrofitted on existing code bases that need to be compatible
with older compilers / language versions.

For any other new language feature, you can just choose to ignore it for your
meant-to-be-compatible code base. But contracts are so valuable to find
bugs in existing software, so you want them everywhere ASAP.

(I'm just repeating an argument I think I heard. This is not my opinion.)

Jens

Received on 2023-10-06 16:35:53