4 ms·
If println panics if the write fails that is kind of cheating, isn't it. Yes, toy C programs do not check the return value of printf. So what.
by akaletF 2y ago
If println panics if the write fails that is kind of cheating, isn't it. Yes, toy C programs do not check the return value of printf. So what.
- dralley 2y agoI would venture to say that most C programs don't check the return value of printf, including ones that ought not to be "toys"
- akaletF 2y agoI don't know. Most serious programs will use write() and then check the return value. In locations where it does not matter (say a test suite that is guaranteed to signal an error but an fprintf() error message could fail in theory) not checking is fine I think. You will not see the message if you get a panic either ...
- sans-seraph 2y ago> Most serious programs will use write() and then check the return value. Similarly in Rust, serious programs will use writeln rather than println, and will receive the standard compiler warning if the Result produced by writeln is ignored.
- toast0 2y agoSetting up your environment so that you have to check for errors or the errors propagate doesn't seem to be cheating when the complaint is that other environments often omit checking for errors even when it matters.