[Mono-list] limited checked exceptions proposal discussion

David Jeske jeske@chat.net
Tue, 8 Apr 2003 11:10:18 -0700


On Mon, Apr 07, 2003 at 02:36:06PM +1000, Fergus Henderson wrote:
> On 30-Mar-2003, David Jeske <jeske@chat.net> wrote:
> > Inferring thrown exceptions is not hard like
> > ML-style type inference -- It's trivial.
> 
> How do you plan to handle virtual methods?

All virtual methods which can be overridden or called outside the
assembly will require throws declarations. From the chart below, this
includes "protected" and "public":

                        virtual      cross-assembly override/call
-----------------------------------------------------------------
           private    not-allowed        not-allowed
          internal      allowed          not-allowed
protected internal      allowed          not-allowed
         protected      allowed            allowed
            public      allowed            allowed

Requiring throws declarations on "protected" and "public" virtual
methods is consistant with the treatment of delegates. Namely, because
virtual methods and delegates are both explaning a type-contract that
someone else may implement:

 (a) the declaration must declare what exceptions can be thrown, and
 (b) the implementor must meet the contract. 

"internal" and "protected internal" virtual methods are allowed, but
are only accessable from within the assembly. Because all
implementations must occur within a single assembly, we can infer that
any exception which appears in an override of the virtual method may
appear at the virtual method call site. This allows us to not require
the "throws" declaration for these methods.

"private" virtual methods are not allowed.

-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net