scope() statements and return

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 3 20:21:13 PDT 2014


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141004/530edd83/attachment.sig>


More information about the Digitalmars-d mailing list