3 ms·
The error bubbling up is a good thing. It at least allows you to find missing error checks in the underlying code. Good luck trying to find an unchecked return
by emsy 8y ago
The error bubbling up is a good thing. It at least allows you to find missing error checks in the underlying code. Good luck trying to find an unchecked return code. It seems you mix up problems innate to exceptions (like messing with the control flow) with user problems (unchecked errors/exceptions).
- electrograv 8y ago> Good luck trying to find an unchecked return code. We're talking about alternate programming languages that handle errors vs exceptions differently, so it's only fair if we consider a language designed from the start not to need exceptions. So let's take Rust, for example: In Rust, it's not a matter of luck at all: You declare whether your return code may be ignored; if not, it's a compile error not to use it.
- Gibbon1 8y agoIn c you can declare a function with __attribute__((warn_unused_result))
- josefx 8y agoNot even used for the C standard library and that would lead to warning spam as every printf call could fail and if there is anything I have never seen it is C code checking the return value of printf.
- Gibbon1 8y ago> C standard library is an mostly an ancient POS
- maxlybbert 8y agoYou would only mark functions where it’s a bad idea to return the error code that way. Printf isn’t a function like that, and fprintf probably isn’t (use case of printing to stderr), but fwrite is.
- maxlybbert 8y ago... “bad idea to ignore the error code” ... It took a few days to notice.
- emsy 8y agoFair enough, error checks should always be enforced. I think errors and exceptions are both valid concepts that solve overlapping problem areas. Java has checked exceptions, so you can statically enforce exception handling.