Re: Try Finally...
From: VBDis (vbdis_at_aol.com)
Date: 10/26/04
- Next message: VBDis: "Re: Try Finally..."
- Previous message: VBDis: "Re: Try Finally..."
- In reply to: Maarten Wiltink: "Re: Try Finally..."
- Next in thread: Duncan McNiven: "Re: Try Finally..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Oct 2004 21:27:42 GMT
Im Artikel <417e1ea5$0$37789$e4fe514c@news.xs4all.nl>, "Maarten Wiltink"
<maarten@kittensandcats.net> schreibt:
>As an opening, I think there should be no retrying from a finally clause
>at all. As Rob(?) said, a finally clause should ideally not even know if
>an exception occurred or not. If one did, retrying should jump back to
>the offending instruction; without one, it should do nothing. Not only
>because there is nothing to retry, but it would cause an infinite loop.
This is one of the BASIC features I learned to love in the past, with Resume,
Resume Next or Resume <label>. But once I found the according code in .NET
MSIL, I saw that the cost is very high for such comfort. The implementation
requires a line table, linking line numbers to code addresses, and an
Inc(LineNo) or LineNo:=nnn at the begin of every line; the further code in the
exception handler is quite lengthy, and I suspect that the .NET MSIL Filter
instruction was introduced for the sole purpose of enabling exception handling
in the BASIC OnError way, instead of SEH. AFAIR the Filter code can not only
access the exception record and signal handled/unhandled, but it also can
specify which exception handler (Resume, ResumeNext...) to use. I had to
consult the MSIL specs and my old disassemblies of the according code, if
anybody is interested in more accurate informations.
>That casts a new light on things. If code that caused an exception can
>be retried, you do indeed need to follow the handler chain first and
>only unwind the stack later, if and when you decided that you're not
>going to retry.
In BASIC the retry starts at the line in that subroutine that implements the
handler, not at the line that really caused the exception. IMO this is a wise
decision, allowing for modifications of the context (i.e. shrink buffer size or
select a different method...), before starting an retry. And since the stack is
unwound before the retry, the application code must not be reentrant; I hope
you know what this means...
DoDi
- Next message: VBDis: "Re: Try Finally..."
- Previous message: VBDis: "Re: Try Finally..."
- In reply to: Maarten Wiltink: "Re: Try Finally..."
- Next in thread: Duncan McNiven: "Re: Try Finally..."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|