On Mon, 04 Oct 2010 22:13:52 +0400, Jonathan M Davis <jmdavisp...@gmx.com> wrote:

On Monday, October 04, 2010 10:37:53 Sean Kelly wrote:
Andrei Alexandrescu Wrote:
> There is still debate on the matter of private methods in interfaces.
> Please bring up in this forum any additional pro and con arguments that
> you might have.

What debate? Private methods don't get a vtbl entry so I don't see how an interface could possibly require one, regardless of in-module visibility.

Except that per TDPL private methods are _supposed_ to be in the vtable:
http://d.puremagic.com/issues/show_bug.cgi?id=4542

The fact that they don't currently is definitely limiting. Personally, I liked what TDPL said about interfaces and private methods, and I don't know what the
debate against them is. It all seemed quite sensible to me.

Regardless, however, private methods really should be properly polymorphic.

- Jonathan M Davis

Interesting enough, you can "override" private methods, yet the override keyword is silently ignored:

import std.stdio;

class A
{
        private void foo()
        {
                writeln("A.foo");
        }
        
        void test()
        {
                foo();
        }
}

class B : A
{
        private override void foo()
        {
                writeln("B.foo");
        }
}

void main()
{
        B b = new B();
        b.test();
}

# dmd private.d && ./private
A.foo

Reply via email to