try/catch idiom in std.datetime

growler growlercab at gmail.com
Fri Nov 22 17:37:50 PST 2013


On Friday, 22 November 2013 at 21:48:14 UTC, Shammah Chancellor 
wrote:

[snip]
>
> No.  scope(failure) is supposed to re-throw the exception.

Where does it say that?

http://dlang.org/statement.html#ScopeGuardStatement

"... scope(failure) executes NonEmptyOrScopeBlockStatement when 
the scope exits due to exception unwinding. ..."


[snip]
> Return's from scope statements should be disallowed now.

I disagree. You cannot return or throw from a scope(exit) or 
scope(success) for obvious reasons, but how a program behaves 
when a scope fails should left to the programmer.

I might be at a DLL or C/C++ boundary and any exceptions 
(Throwable or otherwise) I do not want to escape out of the 
current scope.

I know I could use try-catch, but I find scope is just much 
easier to read.

Cheers G.


More information about the Digitalmars-d mailing list