Bug or feature? std.c.stdlib.exit() breaks RAII

Ashish Myles marcianx at gmail.com
Thu Dec 29 10:43:36 PST 2011


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()?


More information about the Digitalmars-d-learn mailing list