Re: Exceptions and Objects

[email protected] (Jonathan Scott Duff) Mon, 14 Aug 2000 10:56:36 -0500
Newsgroups perl.perl6.language.flow
Message-ID <[email protected]>
On Mon, Aug 14, 2000 at 04:09:41AM -0600, Tony Olekshy wrote:
> $@->CanFoo is an example of semantics that determines whether or
> not the exception is caught; stringification may be an example
> of semantics that comes into play when an exception is caught.

Ah, this is why I started asking I guess.  Some people were proposing
a try/catch like the following:

	try { } 
	catch SomeException { }
	catch SomeOtherException { }
	finally { }

which seems to only catch exceptions based on name.  Which implies to
me that, for exceptions to have useful semantics, they'd have to be
rethrown after they're caught.  I like the following, but it would
also seem that exceptions that aren't handled here would have to be
rethrown so that an upstream catch could handle them.

	try { } 
	catch {				# ALL exceptions
	    switch ($@) { 
		case ^_->name eq 'IO'	{ ... }
		case ^_->canFoo 	{ ... }
                throw $@;		# No cases matched, rethrow
	    }
	}
	finally { }


-Scott
-- 
Jonathan Scott Duff
[email protected]