DMD 0.148 - scope guard

Hasan Aljudy hasan.aljudy at gmail.com
Mon Feb 27 17:27:56 PST 2006


Walter Bright wrote:
> "Hasan Aljudy" <hasan.aljudy at gmail.com> wrote in message 
> news:dtsfm5$1h2i$1 at digitaldaemon.com...
> 
>>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();
>>    }
>>}
> 
> 
> finally does work for on_scope_exit, but it leaves on_scope_success and 
> on_scope_failure hanging. 
> 
> 

Why do we need to handle "on failure" and "on success" any differently 
than a regular scope exit?



More information about the Digitalmars-d mailing list