On Thu, Aug 10, 2000 at 06:43:30PM -0400, Chaim Frenkel wrote:
> >>>>> "GB" == Graham Barr <[EMAIL PROTECTED]> writes:
>
> GB> On Thu, Aug 10, 2000 at 04:34:50PM -0400, Chaim Frenkel wrote:
> >> Nice.
> >>
> >> The continue clause, I assume would re-raise an uncaught exception.
> >> But, a big but. How does the 'else' clause indicate that the exception
> >> was handled?
>
> GB> By not rethrowing it. ie if it does not want to handle the
> GB> error itself it just calls die;
>
> GB> Which will call PROPAGATE on the object in $@, just like perl5, then
> GB> look back up the call-stack for the next eval { }
>
> Hmm, we must be coming from different backgrounds.
>
> I expect my exception handler to rethrow if not handled. I expect
> the continue block to be run under both conditions, and be responsible
> for ensuring consistancy.
>
> Let's look at it from how the validity of the data (or object)
>
> # --> Invariant True
> eval {
> # --> Invariant True
> ....
> # --> Invariant True
> }
> else {
> # --> Invariant might be invalid
> ...
> # --> ????
> }
> continue {
> # --> ????
> ...
> # --> Invariant True
> }
> # --> Invariant True
>
> What would you want at the exit point of the else or the entry point
> of the continue? Is the job of the continue to restore the invariant
> or is it the job of the else clause.
The else it catching the errors. Remeber that with perls eval it is upto
you to deal with $@, perl does not magically die again if you do nothing
as you can ignore it if you want to.
So following on from that the else block deals with the error if it
wants to. One of it's options is to pass it on up the call stack.
The otherwise will always be called on exit of the else block, whether
it be exiting by a natural path or by calling die.
Graham.