Peter Scott wrote:
>
> I still think the explanation can be made simpler with fewer
> forward references.  I'll have another try: [snip, but save]
>
> I note that under these rules it would be possible to have
> "try { ... } finally { }"  with no catch blocks.  I guess
> that's okay.

Have I got news for you.  88v2d1 not only allows that, it allows

    try { } catch { } finally { } catch { }

it also allows

    try { } finally { } finally { }

and this example of its use is given in the draft.

    my ($p, $q);
    try { $p = P->new; $q = Q->new; ... }
    finally { $p and $p->Done; }
    finally { $q and $q->Done; }

    This construct makes sure that if $q is successfully
    constructed, then $q->Done is invoked even if $p->Done
    raises an exception.

Your explanation still assumes try followed by 0 or more
catch clauses, followed by 0 or 1 finally clause.  The draft
does those cases just an you (and I) would want them to, but
it allows for try followed by 0 or more clauses each of which
is either a catch clause or a finally clause.  This mechanism
has been shown to have at least the two uses shown above, it
has a well defined semantics, and it can be easily avoided.

Here's one thing we could do.  We could define a very simple
set of rules for the common but restricted case of a try
followed by an optional catch, followed by an optional finally.
That covers most cases.  Then, we could refer to the more
complete rules for the more complex cases.

Yours, &c, Tony Olekshy

Reply via email to