11 ms·
> Most data structures have invariants that must hold for the data structure to behave correctly. If users can directly read and write members, there's no way f
by xboxnolifes 1y ago
> Most data structures have invariants that must hold for the data structure to behave correctly. If users can directly read and write members, there's no way for the public APIs to guarantee that they will uphold their documented API behaviors.
You can, just not in the "strictly technical" sense. You add a "warranty void if these fields are touched" documentation string.
- Ygg2 1y agoThat's honestly horrible. It's like finding your job is guaranteed by a pinkie promise, or the equivalent.
- xboxnolifes 1y agoMost of the world runs on a handshake.
- Ygg2 1y agoThat's not a valid argument. For most of human existence there was cannibalism and/or human sacrifices. This doesn't mean we should go back to it.
- jcelerier 1y agoisn't that the norm in many places on earth?
- pjmlp 1y agoI prefer liability when devs misuse software with consequences for society infrastructure.
- xboxnolifes 1y agoA language adding private fields does not add liability.
- pjmlp 1y agoIndeed, misusing the library and causing software faults does, so every stone in the way preventing misuse helps.