3 ms·
These protections might be overly fussy in small, one or two person projects. But for programming in the large they are essential as they represent a social co
by haberman 12y ago
These protections might be overly fussy in small, one or two person projects. But for programming in the large they are essential as they represent a social contract between teams.
If you call only my public methods, you can generally expect:
- if my public methods don't work properly, it's a bug
- and I, as the library author, promise to care
- if the internals of my library change, I'll keep my public
functions working if possible.
Disregard my protections and all bets are off. If you cast away const on an object I gave you and then call a non-const method, you might be totally violating the threading model of my library. If you write and complain about this, I will ask why you thought it was ok to cast away const.
Without these annotations it would be much harder to effectively communicate and enforce the parameters within which the library is "promised" to work.