How do I properly exit from a D program (outside main)?
AsmMan via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Sep 15 17:06:45 PDT 2014
On Monday, 15 September 2014 at 23:42:02 UTC, notna wrote:
> how about "return"? :)
>
> there is also "assert"... and pls note, scope could also be
> your friend :O
>
> On Monday, 15 September 2014 at 23:36:56 UTC, AsmMan wrote:
>> Someone said somewhere that call std.c.process.exit() isn't
>> the proper way to exit from a D program since it doesn't
>> terminate some phobos stuff. So what should I use instead of?
>> or there's no a replacement?
Neither assert or return will help. Check out this code example:
void main() {
f();
}
void f() {
if(!foo)
exit(1);
do_something();
}
More information about the Digitalmars-d-learn
mailing list