At 04:38 PM 8/22/00 -0600, Tony Olekshy wrote:
>Peter Scott wrote:
> >
> > I thought the discussion was around how
> >
> >          throw object;
> >
> > could be a run-time error if object ! isa Exception (which is
> > what I think should happen) if
> >
> >          throw LIST;
> >
> > had to have the same semantics as die LIST.
>
>We can't do constuctor and LIST.  The following would be ambiguous:
>
>     my $name = "Exception";  open $name or throw $name;
>
> > I know that sounds weird, but I think whenever it happens, it
> > almost certainly means that the user thought they were throwing
> > an Exception object and picked the wrong one.
>
>I don't see how this can happen.  If one says "throw Foo" and Foo
>is not an exception, one will typically get some message about not
>being able to find method throw for class Foo.  If such a method can
>be found I think it better be invoked, in case I say throw Ball;
>where Ball is not an exception.

I'm just talking about a case like this:

   try   { ... }   # Really must get this operator implemented :-)
   catch { my $ex = mungle($@);
           throw $ex;
   }

   sub mungle {
   # Intended to return an Exception object but accidentally returned a
   # Chocolate::Belgian object instead due to pilot error.
   }

>     sub throw
>     {
>         die $_[0]->isa("Exception") ? $_[0]->new(...)
>             : new Exception::NotException "...",
>                     debug => join(", ", @_);
>         }
>

... which is what you ably addressed here.
--
Peter Scott
Pacific Systems Design Technologies

Reply via email to