2 ms·
Is there any good documentation about contracts? https://en.cppreference.com/w/cpp/language/contracts.html https://en.cppreference.com/w/cpp/language/contracts.
by btown 6mo ago
Is there any good documentation about contracts? https://en.cppreference.com/w/cpp/language/contracts.html https://en.cppreference.com/w/cpp/language/contracts.html is incredibly confusing - its first displayed example seems to be an edge case where the assertion itself causes a mutation?
https://en.cppreference.com/w/cpp/language/function.html#Function_contract_specifiers https://en.cppreference.com/w/cpp/language/function.html#Fun... is vaguely better, but still quite dense.
IMO the syntax makes things hard for a newcomer to the syntax to understand, which I see as core to any programming language's goals of community.
double square_root(double num) asserts_pre(num >= 0)
would have been far more self-evident than just
double square_root(double num) pre(num >= 0)
But I suppose brevity won out.
- steveklabnik 6mo agoI believe that https://isocpp.org/files/papers/P2900R14.pdf https://isocpp.org/files/papers/P2900R14.pdf is the paper, which doesn't mean it's good documentation, as it's meant for modifying the standard. However, in its early sections, it does link to other papers which have more information, and the "proposed wording" section should be where the standardize lives, with the rest of it being context.