At 11:00 PM 8/13/00 -0500, Jonathan Scott Duff wrote:
>On Sun, Aug 13, 2000 at 07:27:47PM -0700, Peter Scott wrote:
> > At 12:22 PM 8/12/00 -0500, Jonathan Scott Duff wrote:
> > Pretty much. It screams O-O for these reasons:
> >
> > An exception is an 'error'. That's already a vague concept.
> >
> > An error has text associated with it, but also a bunch of other attributes.
>
>So it's a structured data type ... where does OOP come into play?
True... but we often use objects to construct reusable structured data
types in Perl. Sure there's things like %ENV and %SIG, and you could
imagine perhaps a %EXCEP whose keys were attribute names, but it just seems
weird. Although given that a program can only have one exception active
per thread I can see some sense in it.
> > They fall naturally into different classes, some of which have subclasses
> > (a File error is-a IO error).
>
>This, to me, seems a mere matter of naming. Was it that OOP already
>had a hierarchical naming system and so it was used?
Could be. I'd be interested in seeing non-OOP proposals that do what I
want exceptions to do, I have a hard time imagining one.
> > Users want to define their own kinds while reusing the semantics of the
> > base class.
>
>What does it mean for an exception to have semantics? When an exception
>is thrown does something special happen whether it's caught or not?
Yes. In my proposal, if it's caught, the catcher examines the exception
object. If it isn't caught, the program dies with the message attribute as
text.
It never occurred to me that someone might want to change that behavior on
a per-exception basis but I guess with an OOP implementation we could make
it possible both on a class and (shudder) an object basis.
>I have only a passing familiarity with exception handling and have only
>used it in "toy" programs. I'm just trying to wrap my mind around the
>whys and wherefors. I understand how it works, but not why it works
>the way it does, any references to exception handling would be much
>appreciated.
A lot of what I'm proposing comes from Java, um... how about
http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html ?
--
Peter Scott
Pacific Systems Design Technologies