Re: Exceptions and Objects
[email protected] (Graham Barr) Tue, 15 Aug 2000 17:41:52 +0100
| Newsgroups | perl.perl6.language.flow |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Aug 15, 2000 at 11:43:41AM -0500, Jonathan Scott Duff wrote:
> On Mon, Aug 14, 2000 at 08:50:41PM -0600, Tony Olekshy wrote:
> > Jonathan Scott Duff wrote:
> > > try { }
> > > catch { # ALL exceptions
> > > switch ($@) {
> > > case ^_->name eq 'IO' { ... }
> > > case ^_->canFoo { ... }
> > > throw $@; # No cases matched, rethrow
> > > }
> > > }
> > > finally { }
> >
> > This is why RFC 88 is working on syntax and semantics for:
> >
> > try { ... } except sub { $_[0]->CanFoo } => catch { ... }
> >
> > which *does* unwind if $_[0] can't Foo (or, if $_[0]->CanFoo or the
> > catch clause throws).
>
> Er, why? What's wrong with just using the switch statement? It seems
> like except and catch are becoming special-purpose switches to me. Is
> it really necessary?
I don't think so. And I hope the final revision of the RFC will show
the try/catch/finally above as one possible solution. Or even eval/else/otherwise
if no new keywords are wanted.
Remember these RFCs are suggestions to Larry, he will make his own decision.
So I would suggest that the RFC should simply list more than one implementation
and show the positives/negatives of each.
Then maybe we can end this thread and move onto other things.
Graham.