[Issue 2051] New: interfaces should allow private methods

Robert Fraser fraserofthenight at gmail.com
Mon Apr 28 03:15:34 PDT 2008


d-bugmail at puremagic.com wrote:
> Consider: 
> 
> interface Foo
> {
>     private void bar();
> }
> 
> class Bar : Foo
> {
> }
> 
> void main()
> {
>     Foo bar = new Bar;
>     bar.bar;
> }
> 
> This code has a link-time error. Removing "private" yields (correctly) a
> compile-time error. So we have a bug already :o).

The error occurs because there's no implementation anywhere, so the 
vtable can't be completed. I'm assuming you're suggesting that this 
should be turned into a runtime error if no implementation is present 
anywhere, but this would be so much harder to update stuff once an 
interface is updated. I can't see any advantages of making this error 
runtime.


More information about the Digitalmars-d-bugs mailing list