Hacker News new | past | comments | ask | show | jobs | submit login
Simple Contracts for C++ [pdf] (open-std.org)
14 points by vmorgulis on Jan 24, 2016 | hide | past | favorite | 1 comment

It's hard to retrofit this to C++.

This proposal has no object invariants, which are one of the most useful kinds of assertions. Especially since you write them once for the object, and they apply to all the public function members. But then you have to clarify when control enters and leaves an object. If you can call a public function member from another function member of the same object, you've re-entered the object. Does the object invariant have to be true when you do that? Spec# addressed that, but this doesn't.

Function calls in assertions are a problem. You'd like to require that such functions not have side effects, so that turning off assertion checking doesn't change program behavior. They don't seem to require this.

Trying to tighten up C++ is like trying to make a colander leakproof. I've had a go at that myself. I've given up and now take the position that Rust is the future.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact