On 11/18/13 1:56 AM, Daniel Murphy wrote:
"Andrei Alexandrescu" <[email protected]> wrote in message
news:[email protected]...
1. Fix scope(failure) and then use it.

scope(failure) picks up Errors as well as Exceptions

That's fine. What the compiler should do for a nothrow function goes as follows. Consider:

void fun() nothrow
{
   statementsA
   scope(failure) statement
   statementsB
}

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.

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");
}


Andrei

Reply via email to