4 ms·
Three reasons: 1. Implementing pre/post condition checks are optional for a conforming compiler. Putting the checks in special docs comments underscores that t
by Nuoji 6y ago
Three reasons:
1. Implementing pre/post condition checks are optional for a conforming compiler. Putting the checks in special docs comments underscores that the checks are optional. The more C way would perhaps be to use pragma.
2. Putting checks either between comments and function signature, function signature and body, or at the start of the signature body visually divides function signature from code that’s actually run.
3. Since these are hard requirements on calling functions the information needs to be in the documentation anyway. This ensures that docs and contracts are always in sync.
But yes, I think your opposition to this is a valid one. It is not ideal, rather it is the best trade off I could find. Given the above.