DMD 0.148 - scope guard
Kyle Furlong
kylefurlong at gmail.com
Sun Feb 26 06:58:48 PST 2006
Dawid Ciężarkiewicz wrote:
> Dawid Ciężarkiewicz wrote:
>> VERSION E:
>> void LongFunction()
>> {
>> State save = UIElement.GetState();
>> onscope {
>> case success: UIElement.SetState(save);
>> }
>> onscope {
>> case failure: UIElement.SetState(Failed(save));
>> }
>> ...lots of code...
>> }
>
> Just came to my mind:
>
> This version is especially neat because it may be simplified to:
> void LongFunction()
> {
> State save = UIElement.GetState();
> onscope {
> case success: UIElement.SetState(save); break;
> case failure: UIElement.SetState(Failed(save));
> }
> ...lots of code...
> }
I really like this idea, cons anyone?
More information about the Digitalmars-d
mailing list