DMD 0.148 - scope guard
Walter Bright
newshound at digitalmars.com
Mon Feb 27 13:36:23 PST 2006
"Ben Hinkle" <bhinkle at mathworks.com> wrote in message
news:dtv8f5$1svn$1 at digitaldaemon.com...
>
> "Walter Bright" <newshound at digitalmars.com> wrote in message
> news:dtr2fg$2vqr$4 at digitaldaemon.com...
>> Scope guards are a novel feature no other language has. They're based on
>> Andrei Alexandrescu's scope guard macros, which have led to considerable
>> interest in the idea. Check out the article
>> www.digitalmars.com/d/exception-safe.html
>
> Note GCC has pretty much the same thing with the "cleanup" attribute
> extension on variables:
> http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Variable-Attributes.html
cleanup only corresponds with on_scope_exit, not the other two. It also only
runs a function with a local variable as a parameter - i.e. it is the same
thing as RAII. It doesn't allow arbitrary code to be executed, nor manage
things like state of a class member, etc.
More information about the Digitalmars-d
mailing list