Open mochaaP opened 2 months ago
Where in Zycore would you like to use this?
UNEXPECTED seems to be the same as the existing FAILED status. Both are used to signal generic failures.
Contrary to exceptions, unexpected errors should not exist with status codes as per design every return value MUST be checked. Not doing that is a bug.
NOT_IMPLEMENTED would be ok to add for me, but is not as useful as a NotImplementedException IMO. It's probably better to call printf() and halt(), abort(), etc in the corpus of an unimplemented function. There is no meaningful runtime action to handle a NOT_IMPLEMENTED code. For the exception case, this is different as it at acts as a shortcut for 1) crashing the program and 2) signaling that the function never returns. In the end, using NOT_IMPLEMENTED or NotImplementedException is always a bug in the code.
UNEXPECTED is more like a guard (e.g. __builtin_unreachable) but with a defined behavior instead. NOT_IMPLEMENTED is for platform-dependent support. I hope this clears the confusion.
Mhh, what would be the benefit of using UNEXPECTED stats code vs the ZYAN_UNREACHABLE macro? IMO unreachable code should really be unreachable. If it is executed, this is clearly a bug and I don't see a valid runtime strategy that a caller should use to handle this status code (besides terminating the application; but then it can as will be done at the root).
Regarding NOT_IMPLEMENTED: I think we have NOT_SUPPORTED for the mentioned use-case.
Regarding NOT_IMPLEMENTED: I think we have NOT_SUPPORTED for the mentioned use-case.
Not in Zycore:
I propose two status code extensions:
p.s. there was also a typo in the comments of
Zycore/Status.h
: