Bug or feature? std.c.stdlib.exit() breaks RAII
AaronP
aaronbpaden at gmail.com
Thu Dec 29 13:34:15 PST 2011
On 12/29/2011 12:43 PM, Ashish Myles wrote:
> On Thu, Dec 29, 2011 at 1:26 PM, Andrej Mitrovic
> <andrej.mitrovich at gmail.com> wrote:
>> Probably the easiest thing to do is to throw a custom exception and
>> catch it somewhere in main() to return your status code. Unlike
>> exit(), throwing will take care of RAII stuff.
>
> Thanks, Andrej. That option had occurred to me, but I figured that
> shouldn't be the way to do things given that most other languages have
> a native exit function. Given that this code transformation isn't
> particularly difficult (put main in a try/catch, have a custom
> exception storing exit code, return the exit code in the catch block),
> would it be reasonable to do a feature request for a
> D-language-supported exit()?
Yeah, really. I'd been using the C exit() as well. Seems like a pretty
fundamental feature. :O
More information about the Digitalmars-d-learn
mailing list