Thread overview | |||||
---|---|---|---|---|---|
|
December 06, 2018 Abstract exit success/failure codes | ||||
---|---|---|---|---|
| ||||
Most operating systems today use the convention of 0 => success, non-zero => fail for exit codes, but not all. Might D offer a standard way to refer to a successful exit code vs. a failing exit code, to foster cross-platform programs out of the box? Some other languages already do this. |
December 06, 2018 Re: Abstract exit success/failure codes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Pennebaker | On Thursday, 6 December 2018 at 03:14:24 UTC, Andrew Pennebaker wrote: > Most operating systems today use the convention of 0 => success, non-zero => fail for exit codes, but not all. Might D offer a standard way to refer to a successful exit code vs. a failing exit code, to foster cross-platform programs out of the box? Some other languages already do this. EXIT_FAILURE and EXIT_SUCCESS are defined in the D module core.stdc.stdlib [1], which corresponds to the standard C header stdlib.h. The convention that 0 means the same thing as EXIT_SUCCESS is part of the C standard [2], so it should be portable to any platform that supports standard C. [1] https://dlang.org/phobos/core_stdc_stdlib.html [2] http://port70.net/~nsz/c/c89/c89-draft.html#4.10.4.3 |
December 06, 2018 Re: Abstract exit success/failure codes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Pennebaker | On Thursday, 6 December 2018 at 03:14:24 UTC, Andrew Pennebaker wrote:
> Most operating systems today use the convention of 0 => success, non-zero => fail for exit codes, but not all.
Well, D follows and offers the C way, but there is also another: return void.
If you return void from main, the runtime library automatically handles the return value. If no exception, it returns success, if exception, it returns failure.
|
Copyright © 1999-2021 by the D Language Foundation