On Tue, Aug 15, 2000 at 11:59:40PM -0600, Tony Olekshy wrote:
> Problem 1:
> 
> In a large lexical scope, you have no preindication that intended
> non-local flow control is in effect until you read all the way to
> the end of the scope.  The equivalent of your example in more human-
> friendly terms is try { } exceptions { }.

Yeah, I realized this later.

> Problem 2:
> 
> If you accidentally forget the "else throw" or whatever, you drop
> the exception on the floor.  Exceptions should propagate unless you
> explicitly and completely handle them.

Okay, so if I define the semantics of my "exceptions" block so that if
control ever makes it to the closing brace, the exception is rethrown
for upstream handlers to take care of, what would be missing then?

Let me draw another picture (with "try" and "catch" this time):

        try {
            # code that may cause exceptions
        } catch {                       # catches ALL exceptions
            switch ($@->^_) {
                case canFoo             { ... ; undef $@ }
                case isa('IOError')     { ... ; undef $@ }
                case isa('Oops')        { ... ; undef $@ }
            }
        }                               # implicit throw here if defined $@
        
To signal that the exception was handled, the programmer undefs $@.
That way if the user wishes to do something when an exception occurs,
but not handle it, they just don't undef $@.

BTW, I hope you guys don't find me frustrating, I'm just trying to
decide what exception handling should look like in Perl to me.

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to