DMD 0.148 - scope guard
Hasan Aljudy
hasan.aljudy at gmail.com
Sun Feb 26 06:58:41 PST 2006
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