digitalmars.D.learn - Can I circumvent nothrow?
- Damian Day (11/11) Apr 26 2014 So I have this procedure:
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/6) Apr 26 2014 You can wrap the contents of shutdown_system() with a try-catch block
- Damian Day (2/10) Apr 26 2014 Oh right, didn't realize it would be that simple. Thank you!!
- Brad Roberts via Digitalmars-d-learn (4/12) Apr 26 2014 Careful here.. it sounds like you're doing work inside a signal handler ...
- Andrej Mitrovic via Digitalmars-d-learn (4/5) Apr 27 2014 Have a look at std.exception.assumeWontThrow:
- monarch_dodra (12/17) Apr 27 2014 Keep in mind that "assume won't throw" will assert *should* an
So I have this procedure: extern (C) void signal_proc(int sn) system nothrow Which can call this: shutdown_system() system nothrow Problem I have is inside "shutdown_system()" I have code that can't possibly be nothrow because their are a lot of subsystems to shutdown. What I've done for now is just strip the nothrow attribute of the C function in core.stdc.signal. It feels very hackish but it works..
Apr 26 2014
On 04/26/2014 06:39 PM, Damian Day wrote:Problem I have is inside "shutdown_system()" I have code that can't possibly be nothrow because their are a lot of subsystems to shutdown.You can wrap the contents of shutdown_system() with a try-catch block and swallow all exceptions that way. Ali
Apr 26 2014
On Sunday, 27 April 2014 at 01:53:15 UTC, Ali Çehreli wrote:On 04/26/2014 06:39 PM, Damian Day wrote:Oh right, didn't realize it would be that simple. Thank you!!Problem I have is inside "shutdown_system()" I have code thatcan'tpossibly be nothrow because their are a lot of subsystems toshutdown. You can wrap the contents of shutdown_system() with a try-catch block and swallow all exceptions that way. Ali
Apr 26 2014
On 4/26/14, 6:39 PM, Damian Day via Digitalmars-d-learn wrote:So I have this procedure: extern (C) void signal_proc(int sn) system nothrow Which can call this: shutdown_system() system nothrow Problem I have is inside "shutdown_system()" I have code that can't possibly be nothrow because their are a lot of subsystems to shutdown. What I've done for now is just strip the nothrow attribute of the C function in core.stdc.signal. It feels very hackish but it works..Careful here.. it sounds like you're doing work inside a signal handler that's likely to be unsafe / undefined. There's very very little that you can safely do inside a signal handler. Hit google and search for async signal safe.
Apr 26 2014
On 4/27/14, Damian Day via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:So I have this procedure.Have a look at std.exception.assumeWontThrow:
Apr 27 2014
On Sunday, 27 April 2014 at 08:04:54 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote:On 4/27/14, Damian Day via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Keep in mind that "assume won't throw" will assert *should* an exception actually be thrown. If the function actually can and will throw, but you simply don't care, you'd need a "squelchException" (which we don't have), or more simply, just: //---- try { myCode(); } catch (Exception){} //----So I have this procedure.Have a look at std.exception.assumeWontThrow:
Apr 27 2014