try/catch idiom in std.datetime

Shammah Chancellor anonymous at coward.com
Fri Nov 22 13:48:15 PST 2013


On 2013-11-22 03:03:15 +0000, Jesse Phillips said:

> On Friday, 22 November 2013 at 02:35:40 UTC, Shammah Chancellor wrote:
>> void someFunc() // nothrow
>> {
>> scope(failure) { writeln("What?");} <-- NEVER EXECUTED?!
>> scope(failure) {
>> writeln("Failed in someFunc()");
>> return;
>> }
>> throwingFunction();
>> }
> 
> That does exactly as expected:
> 
> void someFunc()
> {
>      try {
>          try {
>              throwingFunction();
>          } catch {
>              writeln("Failed in someFunc()");
>              return;
>          }
>      } catch {
>          writeln("What?");
>      }
> }

No.  scope(failure) is supposed to re-throw the exception.  Remember 
that the original proposal for scope(failure), etc. were using a stack 
of delegates.   The rewriting to try/catch is new and supposed to be 
functionally equivalent.  Return's from scope statements should be 
disallowed now.



More information about the Digitalmars-d mailing list