gnu-arch-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnu-arch-users] Nit


From: Tom Lord
Subject: Re: [Gnu-arch-users] Nit
Date: Tue, 21 Oct 2003 09:11:15 -0700 (PDT)


    > From: "Mark A. Flacy" <address@hidden>

    > Because many authors will think that their software layer should throw
    > certain exceptions and only those exceptions.  

That's a good principle but it's only half the story.

Each call should only _expect_ certain exceptions and no exception
should get past a call-site that doesn't explicitly say it's expected.

Suppose I add a new throw to a function I maintain -- a new exception
that that function might throw.  Must I find all callers and make sure
that the new exception type won't screw them up?

For a while I was thinking it could all be done with just
declarations:

        Module A declares what exceptions it can generate.

        Module B uses A and declares what exceptions it thinks A can
        generate.

but that doesn't quite cut it.  Module A might generate a no_such_user
exception that I actually want to forward from some call sites into A
but not from others.   I think you really do want a per-call-site
enumeration of forwarded exceptions.

    > We've beaten into most of our designers that if you aren't going
    > to do anything with the exception other than re-throw it, don't
    > catch the damned thing.  That's a runtime cost for no purpose.

If it were really an issue a compiler could do a good job with that.

    > Java programmers should never catch Exception, print nothing and
    > do nothing with the exception.  Bad idea.

By default, they should catch Exception all over the place and abort
-- letting through only those exceptions they explicitly intend to.
The language should be extended with syntax to make that easy.

-t




reply via email to

[Prev in Thread] Current Thread [Next in Thread]