I've read the C part of the proposal mentioned above. I think it's an attempt to introduce a universal mechanism,
for something that simply has no universal solution. Also it's a bit nasty with macros/syntax. It has to be because it has
to deal with existing C code. For C2 that restriction is not there and that is exactly why I believe we can do
better.
Although I don't have a single universal solution in my, I do have multiple non-universal ones that can maybe be
improved by some language support:
- It would be nice to rid calling code of error handling by placed that in another 'layer'/place. This can currently be
achieved with longjmp. The programmer must make sure the state remains solid (no mem leakage etc) when jumping. - C has a habit of (ab)using special return values for error values. Like value -1 for file handles. I think this is fine for some things. It does
force a cast sometimes, because the result is signed instead of unsigned to support this - For some errors, a larger performance penalty is fine since it's a non-common situation anyways. But for others where
failure is a common case, the penalty might not be acceptable. - returning a tuple (=overhead) for situations where failure is rare, using the 'other-layer' approach might be better.