scope() statements and return
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 3 21:47:44 PDT 2014
On Saturday, 4 October 2014 at 03:21:23 UTC, ketmar via
Digitalmars-d wrote:
> On Sat, 04 Oct 2014 03:01:14 +0000
> deadalnix via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
>
>> True for return, but throw is a stupid limitation( as it do
>> not prevent the scope to throw at all, simply forc to hide it,
>> which is only worse).
> scope(exit) {
> some-cleanup-code
> thisCanThrow();
> some-more-cleanup-code
> }
>
> and what we should do with "some-more-cleanup-code" if
> "thisCanThrow"
> throws? it's breaks the promise that all cleanup code was
> executed
> prior to exiting. if i'm writing
> `collectException(thisCanThrow());`,
> i'm making my intents clear: "ok, i know that it can throw and
> i'm
> fully responsible to ignoring that here". yet silently allowing
> functions that throws in this context is disasterous, as it
> nullifies
> the promise on cleanup code. then i have to write such
> abominations:
>
> scope(exit) {
> some-cleanup-code
> scope(exit) some-more-cleanup-code;
> thisCanThrow();
> }
>
> WUT?! this is hard to read and unnecessary complicated.
Write this in sepeareted scope statement?. problem solved.
Also, we have exception chaining, so that's all good.
More information about the Digitalmars-d
mailing list