scope() statements and return

monarch_dodra via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 5 07:53:37 PDT 2014


On Sunday, 5 October 2014 at 12:36:30 UTC, ketmar via 
Digitalmars-d wrote:
> On Sun, 05 Oct 2014 11:28:59 +0000
> monarch_dodra via Digitalmars-d <digitalmars-d at puremagic.com> 
> wrote:
>
>> In theory, you should seldom ever catch Errors. I don't 
>> understand why "scope(exit)" are catching them.
> 'cause scope(exit) keeps the promise to execute cleanup code 
> before
> exiting code block?

Promises hold provided the precondition your program is in a 
valid state. Having an Error invalidates that precondition, hence 
voids that promise.

RAII also makes the promise, but you don't see Errors giving much 
of a fuck about that.


More information about the Digitalmars-d mailing list