[Mono-list] exceptions and ECMA issues
Paolo Molaro
lupus@debian.org
Mon, 27 Aug 2001 10:45:11 +0200
On 08/23/01 Carl R. Witty wrote:
> > Basically it says that if an exception id thrown, control is transfered to the
> > matching catch block [1] and only later to the finally block [2].
> > Partition I, instead, claims that a matching catch block is searched, but
> > before executing it, control is transfered to the finally block
> > (section 11.4.2.2.):
> >
> > --snip snip--
> > If a match is not found in the current method, the calling method is searched, and so on. If no match is found
> > the CLI will dump a stack trace and abort the program. If a match is found, the CLI walks the stack back to the
> > point just located, but this time calling the finally and fault handlers. It then starts the corresponding exception
> > handler. Stack frames are discarded either as this second walk occurs or after the handler completes, depending
> > on information in the exception handler array entry associated with the handling block.
> > --snip snip--
>
> I think you're misreading the specification here.
>
> Let me give an example. (Warning: I don't know C#; this is almost
> certainly not the correct C# exception handling syntax.)
>
> try {
> ...
> try {
> throw ...;
> } finally {
> // finally handler A
> }
> } catch {
> // catch handler B
> } finally {
> // finally handler C
> }
>
> My reading of the paragraph you quoted above is that you must execute
> "finally handler A" before executing "catch handler B". The other
> paragraph you quoted (that I cut from my reply) says you must execute
> "catch handler B" before "finally handler C".
That is the problem. Partition I is quite clear that the finally handler
needs to be execute before the catch handler is executed.
What if the code was simply:
> try {
> ...
> throw ...;
> } catch {
> // catch handler B
> } finally {
> // finally handler C
> }
In this case you'd need to run finally handler C before catch handler B and
that would be backwards.
lupus
--
-----------------------------------------------------------------
lupus@debian.org debian/rules
lupus@ximian.com Monkeys do it better