4 ms·
The C++ people are trying to refit ownership to the language without adding a borrow checker. This is painful. They've made it possible to write code that expre
by Animats 8y ago
The C++ people are trying to refit ownership to the language without adding a borrow checker. This is painful. They've made it possible to write code that expresses ownership, but they can't catch all the places where the abstraction leaks.
string_view is really a non-mutable borrow. But the compiler does not know this.
- fooker 8y ago> but they can't catch all the places where the abstraction leaks. Why does static analysis not work here?
- deleted 8y ago[deleted]
- kllrnohj 8y agoIt does, it's just a warning and not an error. And also experimental. But it does exist, and does catch some of these errors. Example: https://godbolt.org/z/CZTfSx https://godbolt.org/z/CZTfSx
- humanrebar 8y agoI'd rather run diagnostics as a separate CI pass, so warnings work for me perfectly.
- pjmlp 8y agoNot quite true, Google and Microsoft are precisely adding a borrow checker to their static analysis tools. https://herbsutter.com/2018/09/20/lifetime-profile-v1-0-posted/ https://herbsutter.com/2018/09/20/lifetime-profile-v1-0-post...
- int_19h 8y agoIt's still strictly better than a language with no borrow checker and no way to express ownership (other than comments), like C, or C++ itself before all the smart pointers.