The scope of scope(exit)
Hasan Aljudy
hasan.aljudy at gmail.com
Thu Mar 9 22:34:09 PST 2006
Walter Bright wrote:
> "Derek Parnell" <derek at psych.ward> wrote in message
> news:1amv63k5pimu6.q5fyzezd5ew5.dlg at 40tude.net...
>
>>The following code did not work as I expected it to.
>
>
> Think of it like:
>
> int Foo(int x)
> {
> int y;
> y = x;
> try
> {
> return y;
> }
> finally
> {
> if (x < 5) y += 9;
> }
> }
>
> which should make it clear. The reason it works this way is because the
> return expression can be arbitrarilly complicated, and can throw exceptions.
> So the exit code must be executed *after* the return value is computes.
>
>
What happens when an exception is thrown inside the scope(exit) block?
More information about the Digitalmars-d-learn
mailing list