Re: return command
- From: "TJC Support" <jvsREMOVE@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 20 Dec 2005 16:44:52 -0600
"marc hoffman" <mh@xxxxxxxxxxxxxxx> wrote in message
news:43a878c0$1@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> right. but if you "exit" es executing, by definition there wasn't an
> exception (or it wouldn't have gotten to tour "exit"). so the behavior of
> finally in case you "exit" cannot depend on whether there's an exception,
> because when you're exciting, there never is an exception ;)
Marc,
This is a good learning experience for me! I've done some experiementing,
like so:
try
// anything here
exit;
finally
MessageDlg ('finally block executed', mtInformation, [mbOK], 0);
end;
Obviously, you're absolutely right, and the message dialog does appear.
This is great! I have some old code to revisit, where if a test condition
was met, I manually freed something that was also freed in the finally block
and then exited. I guess this is a good reason to limit the use of exit,
huh?
I tried substituting halt for exit, and it halts without executing the
finally block, which is what I expected.
Also substituted a goto that landed me just after the last end, and that
wouldn't compile. I find it interesting that I can redirect the flow out of
the try..finally block and the function and it allows that and automatically
executes the code in the finally block, but it won't let me redirect flow
out of the try..finally block but stay within the function. Wonder why it
allows one but not the other? At first glance it would seem that the
consistent thing to do would be to allow the goto, but automatically execute
the code in the finally block. Not that I wanna use a goto in that way (or
any way), but it just didn't seem consistent to me.
Thanks,
Van
.
- References:
- Re: return command
- From: Leonel
- Re: return command
- From: Ryan McGinty
- Re: return command
- From: TJC Support
- Re: return command
- From: marc hoffman
- Re: return command
- From: TJC Support
- Re: return command
- From: marc hoffman
- Re: return command
- Prev by Date: Re: ActiveX Forms in Delphi 2006
- Next by Date: Re: Does BDS2006 Persist Code Folding?
- Previous by thread: Re: return command
- Next by thread: Re: return command
- Index(es):
Relevant Pages
|