www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Abstract exit success/failure codes

reply Andrew Pennebaker <andrew.pennebaker gmail.com> writes:
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.
Dec 05 2018
next sibling parent Paul Backus <snarwin gmail.com> writes:
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
Dec 05 2018
prev sibling parent Adam D. Ruppe <destructionator gmail.com> writes:
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.
Dec 06 2018