downs Wrote: > auto var = hairilyAllocatedObject(); > scope(exit) cleanupObject(var); > > sock.send("<html><head></head><body>"); > scope(exit) sock.send("</body></html>"); > > logln("Digraph D {"); > scope(exit) logln("}"); > > SDL_LockSurface(display.surface); > scope(exit) SDL_UnlockSurface(display.surface); > > auto dg = { performComplexExitCleanupDuty; }; > scope(exit) dg(); > .... > dg = dg /apply/ (proc dg) { moreCleanup; dg(); }; > .... > /* Half a dozen different ways of leaving the function go here */ > > auto backup = var; var = newValue; > scope(exit) var = backup;
Yes fine. You demonstrate the cool use of scope(exit) but this is a bit like kidding yourself and conscientiously thinking you didn't *actually* tell a lie because you just withheld information. Conspicuous, by the absence of, in your examples is any use of scope(exit) inside curly-brace scope statements embedded *inside* a function. Your examples look fine if one assumes scope(exit) as relating to function scope.