DMD 0.148 - scope guard

Unknown W. Brackets unknown at simplemachines.org
Sun Feb 26 10:56:44 PST 2006


Honestly, as ugly as the syntax is, I must admit I like the grouping of 
the start and end conditions together.

That's one thing I've always thought strange about programming; people 
talk about functions and classes and all the different aesthetic and 
linear/non-linear relationships between them, but in the end it is all 
completely and totally linear, when for many cases that doesn't make sense.

-[Unknown]


> Walter Bright wrote:
>> "John Reimer" <terminal.node at gmail.com> wrote in message 
>> news:dtrg0e$c9k$1 at digitaldaemon.com...
>>
>>> Nice feature, but rather ugly to look at; although, I'm not sure how 
>>> something like that could be made to look pretty.
>>
>>
>> I think it's ugly, too, but I just couldn't come up with anything 
>> significantly better.
>>
>>
>>> Nonetheless the scope guard looks like something I should read up on.
>>>
>>> Thanks for another good release.
>>
>>
>> You're welcome.
>>
> 
> Why not just reuse "finally"?
> 
> void func()
> {
>     init_some_reource();
>     foo(); // foo throws an exception
>     //func doesn't catch the exception
>     //but it has a finally clause
> 
>     finally  //aka on scope exit, whether success or fail
>     {
>         release_the_resource();
>     }
> }



More information about the Digitalmars-d mailing list