scope(exit) considered harmful

Walter Bright newshound1 at digitalmars.com
Sun Nov 8 12:23:31 PST 2009


Justin Johansson wrote:
> C++ constructors/destructors and stack-unwinding mechanism
> are considered FREAKING AWESOME.

Ok, good. Now write (using C++ RAII) the following where both 
transactions must succeed or neither:

void foo()
{
     A();
     scope (failure) undo_A();
     B();
     scope (failure) undo_B();
     writeln("A and B succeeded!");
}



More information about the Digitalmars-d mailing list