On Thu, Oct 06, 2005 at 18:11:38 +0100, Peter Haworth wrote:

> The highest level exception is the only one a caller has any right to deal
> with, but even then it doesn't really know what will happen if it resumes
> some random continuation attached to the exception.

But then we gain nothing

> >     CATCH {
> >             when some_kind_of_error {
> >                     $!.continue($appropriate_value_for_some_kind_of_error)
> >             }
> >     }
> 
> That just gives me the willies, I'm afraid.

Why?

        when i can't open a file and $! tells me why i couldn't open, i
        can resume with an alternative handle that is supposed to be the
        same

        when I can't reach a host I ask a user if they want to wait any
        longer

        when disk is full I ask the user if they want to write somewhere
        else

        when a file is unreadable i give the user the option to skip

These handlers are progressively more knowlegable of the code
they're dealing with, but they don't touch the actual guts - that's
the whole merit of continuable exception, because otherwise you
might aswell just start over.

These are 100% reusable in the first exception handler, and not
reusable but still applicable to an opaque call at the last handler.
It doesn't matter who opens the file file, the exception handler
will produce the same effect but in a different way.

        CATCH {
                when Error::IO::... {
                        open ...
                }

                when MyApp::Timeout {
                        ask_user_to_continue_or_abort();
                }
                ...
        }
        
-- 
 ()  Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418  perl hacker &
 /\  kung foo master: /me dodges cabbages like macalypse log N: neeyah!

Attachment: pgpQfW4BcQBM2.pgp
Description: PGP signature

Reply via email to