scope guards
Messenger via Digitalmars-d
digitalmars-d at puremagic.com
Fri Aug 8 01:37:35 PDT 2014
On Friday, 8 August 2014 at 00:27:21 UTC, Jonathan M Davis wrote:
> On Thursday, 7 August 2014 at 20:59:45 UTC, Messenger wrote:
>> On Thursday, 7 August 2014 at 20:54:02 UTC, Jonathan M Davis
>> wrote:
>>> I'd say that if you're trying to use scope in any situation
>>> where you'd try and handle an exception, then you're using it
>>> wrong.
>>
>> But it's super convenient.
>
> It fundamentally doesn't work to handle an exception with a
> scope guard. They rethrow the exception.
void fun() {
scope(failure) return;
throw new Exception(__FUNCTION__);
}
void main() {
import std.exception;
assertNotThrown(fun());
}
More information about the Digitalmars-d
mailing list