DMD 0.148 - scope guard

Walter Bright newshound at digitalmars.com
Tue Feb 28 10:05:05 PST 2006


"Mike Capp" <mike.capp at gmail.com> wrote in message 
news:du1ire$1h1s$1 at digitaldaemon.com...
> When I first saw Andrei's paper it struck me that what made things painful 
> in
> C++ was the lack of usable closures. Since D is pretty good in this 
> regard,
> could the same effect have been achieved with a less sugary but more 
> regular
> approach reusing RAII-auto syntax, e.g.
>
> # import std.scopeguard;
> # auto Guard onOk = new OnScopeSuccessGuard(&mySuccessFunc);
> # auto Guard onFail = new OnScopeFailureGuard(function { /* ad hoc code 
> */ });
>
> with something like C++'s std::uncaught_exception in the Guard subclass
> destructor implementations to discriminate exit conditions?

I don't know a way to make that work as cleanly. 





More information about the Digitalmars-d mailing list