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@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.

Reply via email to