Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
inaba46256yTry and find the sleep functions and then count the inconsistencies between them 😂😂
-
what a crippled explanation. Traditionally (in C at least) the return code on success is 0, which is false as a boolean. It also makes much more sense than returning booleans, because then you can have error codes. and there is really only one way the function can succeed, so it should be 0. and it even works terminologically with true and false if you ask: "Did an error occur?"
So just return false if everything went ok. -
@greg-
certainly the best solution in most cases, although this requires the exception to be caught appropriately, whereas the return type is intrinsic to the functions type signature and can just aswell be ignored. -
devios157706y@simulate The 0-on-success I think is more of a Unix convention than a C one. In my experience it’s more common for boolean results to be true on success, but it’s probably way less agreed-upon hence running into problems like this.
In C it’s more common to pass an error handle in and checking to see if it has been set after calling the function.
Seems reasonable
joke/meme