Method Bodies in Interfaces -- Why Not?

Neal Gafter neal at
Sat Mar 14 13:32:56 PDT 2009

I think adding extension methods as C# does is both simpler and more
powerful than adding method bodies to an interface.  See for a very brief glossy.
I do not plan to submit a proposal for this.

On Tue, Mar 10, 2009 at 4:38 PM, David Walend <david at> wrote:
> A lot of us spend energy dealing with the fact that we can not add
> methods to interfaces. We can't add methods to interfaces because
> everything that implements those interfaces would break. We could get
> around that by letting interface-defined methods have method bodies.
> The resulting problem is that the compiler would not be able to choose
> between or order method bodies with the same signature. (As I
> understand it, that's why interfaces can't have method bodies.)
> It's modestly rare for classes to inherit two interfaces that define
> methods with the same signature in the wild. What happens if the JLS
> were to relax the constraint?
> I imagine a few options:
> With multiple inheritance, if different implemented interfaces define
> bodies for methods with the same signature then:
> 1) Give the developer a compile error or
> 2) Inherit neither method body and force the developer to implement
> something himself or
> 3) Inherit neither method body, force the developer to implement
> something himself, and give him some way to access to all the inherited
> implementations.
> That would let us out of some of our more painful contortions. What
> are the holes in that idea?
> Thanks,
> Dave
> david at

More information about the coin-dev mailing list