Re:Why should I have written ZeroMQ in C, not C++ (2012)
by emsy on Thursday December 13, 2018 @08:33AM
(#18672158)
Fair 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.
Re:Why should I have written ZeroMQ in C, not C++ (2012)
by Gibbon1 on Wednesday December 12, 2018 @10:22PM
(#18669636)
In c you can declare a function with __attribute__((warn_unused_result))
Re:Why should I have written ZeroMQ in C, not C++ (2012)
by josefx on Thursday December 13, 2018 @04:30AM
(#18671029)
Not 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.
Re:Why should I have written ZeroMQ in C, not C++ (2012)
by maxlybbert on Thursday December 13, 2018 @12:37PM
(#18674232)
You 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.
Re:Why should I have written ZeroMQ in C, not C++ (2012)
by maxlybbert on Saturday December 15, 2018 @01:29PM
(#18689626)
... “bad idea to ignore the error code” ...
It took a few days to notice.
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.