scope(exit) considered FREAKING AWESOME
downs
default_357-line at yahoo.de
Sun Nov 8 04:40:38 PST 2009
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;
More information about the Digitalmars-d
mailing list