scope guards

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 7 17:27:19 PDT 2014


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. It's clearly not what it was 
designed for. It was designed for making sure that certain things 
happen when an exception is thrown or regardless of whether an 
exception is thrown. But it's just not designed for actually 
handling exceptions.

- Jonathan M Davis


More information about the Digitalmars-d mailing list