Peter Scott wrote:
> Tony Olekshy wrote:
> >Peter Scott wrote:
> > > Tony Olekshy wrote:
> > > >
> > > > try { TryToFoo; }
> > > > catch { TryToHandle; }
> > > > finally { TryToCleanUp; }
> > > > catch { throw "Can't cleanly Foo."; };
> > > >
> > > > In our production code we often add such blocks to major
> > > > API entry points; that is how we get unwind stack
> > > > tracebacks like the one shown in RFC 88.
>
> Okay, I see. Unfortunately this violates the no-daisychaining
> rule.
RFC 88 v2d1 allows a catch after a finally. It doesn't daisy-
chain catch clauses, but after a finally, catch clauses are
looked for again. Thats why rule 3 says:
If a trap block raises an exception or returns true, then
whether or not the catch clause raises an exception, any
succeeding try/catch clauses up to the next finally clause are
skipped (for the purpose of the "next" iterator in rule 2).
> I see why you want it, though. That does look nice like that.
> Without it you need to:
>
> try {
> try { TryToFoo; }
> catch { TryToHandle; }
> finally { TryToCleanUp; }
> }
> catch { throw "Can't cleanly Foo." }
That's it. You can do anything with nested simple trys, until
you run off the right of the page. What I believe we're working
toward is a reasonable set of syntactic and semantic extensions
that will allow the common to be easy. I don't really care what
happens with bizarre abuse of the mechanism, I just don't want
to make easy to accidentally abuse the mechanism.
> There may be other issues here though. I'm not an expert on
> program flow design, so this may be wrong, but it seems to me
> that there ought to be a distinction between some of the cases
> you're collapsing above: [list snip] Do I have that list right?
> Especially #3?
Thanks for the truth table Peter, I've reformatted it a bit,
and added a reason for each case. The key is 1 = succeeds,
0 = fails, x = skipped. I think case 3 is correct.
TryTo TryTo TryTo | Post Finally Throw
Foo Handle CleanUp | Description
---------------------------+--------------------------------------
1. 1 x 1 | No. We did Foo and cleaned up.
2. 1 x 0 | Yes. We did Foo but didn't clean up.
3. 0 1 1 | No. We didn't Foo but did Handle it,
| and then we cleaned up.
4. 0 1 0 | Yes. We didn't Foo but did Handle it,
| but then we didn't clean up.
5. 0 0 1 | Yes. We didn't Foo and didn't Handle
| it, even though we did clean up.
6. 0 0 0 | Yes. We didn't do anything right!
> Rats. It just doesn't look right the way you have it.
> There shouldn't be anything after a 'finally' block.
Ok, I plead the TIMTOWTDI defense ;-)
Yours, &c, Tony Olekshy