DMD 0.148 - scope guard

Dawid Ciężarkiewicz dawid.ciezarkiewicz at gmail.com
Sun Feb 26 04:41:55 PST 2006


Dawid Ciężarkiewicz wrote:
> What do you think? Maybe later we'll come with better ideas.

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

VERSION E:
void LongFunction()
{
    State save = UIElement.GetState();
    onscope {
        case success: UIElement.SetState(save);
    }
    onscope {
        case failure: UIElement.SetState(Failed(save));
    }
    ...lots of code...
}



More information about the Digitalmars-d mailing list