try/catch idiom in std.datetime

Daniel Murphy yebblies at nospamgmail.com
Mon Nov 18 09:00:56 PST 2013


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:l6d9ki$ok6$1 at digitalmars.com...
>
> First off, statementsA must not throw. Then, if statementsB may throw, 
> then look at what statement throws. If statement always throws an Error, 
> then accept the code. This is because the scope(failure) effectively 
> translates whatever exception into an Error, and it's legal for a nothrow 
> function to throw Error.
>

Yes.

> Currently it looks like the presence of scope(failure) simply makes the 
> function seem legit, no matter what.
>
> void fun() nothrow
> {
>    scope(failure) {}
>    throw new Exception("so sue me");
> }
>

Yes, obviously a bug.  The compiler is missing the rethrow.

My point was only that try-catch(Exception) and scope(failure) do not have 
the same semantics. 




More information about the Digitalmars-d mailing list