scope guards
David Nadlinger via Digitalmars-d
digitalmars-d at puremagic.com
Sat Aug 9 08:46:57 PDT 2014
On Saturday, 9 August 2014 at 11:51:06 UTC, Idan Arye wrote:
> On Saturday, 9 August 2014 at 00:17:07 UTC, Jonathan M Davis
> wrote:
>> I suspect that it says that because someone complained about
>> the error talking about finally when they had used scope(exit)
>> and not finally. The fact that scope statements get lower to
>> try-catch-finally blocks allow for a few screwy things that
>> were not intended. Whether those things will be left in or
>> made illegal at this point is another matter, but I'm sure
>> that it was never the intention that anyone be allowed to
>> return from any kind of scope statement or do anything else
>> which would cause the exception to not be rethrown.
>>
>> - Jonathan M Davis
>
> If that was the case, the error would have said it's illegal to
> throw from "finally or scope bodies". The fact that it
> specifically specifies `scope(exit)` and `scope(success)` and
> leave out `scope(failure)` means that whoever wrote that error
> message made a conscious decision that it's OK to return in
> `scope(failure)`.
Nope. The current wording of the error message resp. the source
code for handling it simply resulted from a conservative fix for
rewrite internals being leaked into the diagnostics:
https://issues.dlang.org/show_bug.cgi?id=6889
In other words, nobody made a "conscious decision" that it is
okay to return in scope(failure). It's just a consequence from
the fact that it is rewritten into a catch block instead of
finally {} like the others.
Cheers,
David
More information about the Digitalmars-d
mailing list