SG22 poll on C++ Contracts syntax
Contracts are a new feature that is being designed for the upcoming version of C++. If you want to know more about how this feature works in general, please check out our Contracts Working Paper, P2900.

SG21 (The C++ Contracts Study Group in WG21) is requesting the opinion of SG22 (The C/C++ Liaison Group) on which candidate syntax for C++ Contracts would make it easier to adopt Contracts also for the C standard, ideally in a way that offers some useful C/C++ compatibility.

Thank you for helping us by filling in this form!

The proposed new syntactic constructions are preconditions and postconditions (both of which go on function declarations) and assertions (which are statements or expressions inside a function body). Postconditions can optionally name the return value of a function (user-defined identifier before the colon). The two candidate syntax proposals for C++ Contracts are: 

P2935R3, aka the "attribute-like syntax":

  int f(int i)
    [[ pre: i >= 0]]
    [[ post r: r > i ]] 
  {
    [[assert: x > 0]]
    return i + x;
  }

P2961R1, aka the "natural syntax":

  int f(int i)
    pre (i >= 0)
    post (r: r > i)
  {
    assertexpr (x > 0)   // *see below
    return i + x;
  }

// *this might end up being `assertexpr`, `contract_assert`, or some other keyword that isn't exactly `assert`, to avoid a name clash with the existing macro from assert.h
Logg på Google for å lagre fremdriften din. Finn ut mer
Your Name *
Your syntax preference *
Please provide some rationale for your preference *
Any other comments? (optional)
Send
Tøm skjemaet
Send aldri passord via Google Skjemaer.
Dette innholdet er ikke laget eller godkjent av Google. Rapporter uriktig bruk - Vilkår for bruk - Retningslinjer for personvern