DMD 0.148 - scope guard

John Reimer terminal.node at gmail.com
Sun Feb 26 04:47:56 PST 2006


Dawid Ciężarkiewicz wrote:
> Walter Bright wrote:
> 
>> 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
> 
> Concept is really promising. Syntax ... well ... :D
> 

<snip>

> 
> VERSION B:
> void LongFunction()
> {
>     State save = UIElement.GetState();
>     scope (success) {
>         UIElement.SetState(save);
>     }
>     scope (failure) {
>         UIElement.SetState(Failed(save));
>     }
>     ...lots of code...
> }
> 

<snip>


I like something similar to the "scope" keywords. That looks quite 
promising.

VERSION B +1

-JJR



More information about the Digitalmars-d mailing list