4 ms·
I think widening post conditions may have to be possible in some cases. In my experience, programs should only depend on three possible error states: ok, eagain
by asdfasgasdgasdg 5y ago
I think widening post conditions may have to be possible in some cases. In my experience, programs should only depend on three possible error states: ok, eagain, and everything else. I guess it's fine for library authors to promise more, but I'd only do so in the case where I think that calling code can respond with more specificity to other conditions, which I think is pretty rare.
- jnxx 5y agoMight in some cases be OK, but it is also how you get "general protection fault" and rampant uncaught exceptions in some earlier versions of Windows.
- asdfasgasdgasdg 5y agoIn the protobuf library, there are some protections against cases like this. For example, they add extra enum values that are explicitly labeled as "do not use" to prevent switch statements from assuming that an enum is complete and future-proof. https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/compiler/cpp/cpp_enum.cc#L131-L134 https://github.com/protocolbuffers/protobuf/blob/master/src/...