News for hackers. Stuff that matters.
Re:Sshole by xorcist on Thursday November 05, 2026 @12:47PM (#50382029)
This argument is weak. C, and specifically libc, has errno. The error code is there. Not in band.

But there has to be something in the payload field when it is not applicable. A null is perfectly fine.

The argument for changing that to "", if I understand the above linked discussion correctly, was that some users of this api threw away errors and a dummy value would be harder to ignore. You could argue that these behaviours are less common in Rust or Go, but that's not a technical difference.

The world is not perfect and sometimes you really need to work around bad users. Even in Rust or Go. I am not convinced this was such a case. If you are convinced it was it would still have been better to select a less trivial dummy value (such as ":ERROR:*").

Re:Sshole by forresthopkinsa on Thursday November 05, 2026 @03:07PM (#50383789)
> But there has to be something in the payload field when it is not applicable

Not in languages with ergonomic sum types. A `Result` or `Either` will have no payload field on the error type. The compiler won't let you dereference it.

Re:Sshole by aidenn0 on Thursday November 05, 2026 @05:55PM (#50385716)
This is wrong. errno is not to be used to detect errors, only to get the cause of the error once an error has been detected.
Re:Sshole by lemonwaterlime on Friday November 06, 2026 @10:12AM (#50393300)
In Haskell, one would return a Maybe or an Either here.

    Maybe
    ——————
    Just hash
    Nothing

    For Either
    ————————————
    Left err
    Right hash
The program would be designed around not allowing this failure mode to even be possible.