|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.ide digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript electronics |
digitalmars.D.bugs - [Issue 2051] New: interfaces should allow private methods
http://d.puremagic.com/issues/show_bug.cgi?id=2051 Summary: interfaces should allow private methods Product: D Version: unspecified Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: andrei metalanguage.com 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). Adding a function void bar() {} to Bar keeps the link-time error in vigor, whether or not the function is private. Now, if we want D to allow Sutter's NVI idiom (http://www.gotw.ca/publications/mill18.htm) easily, it would need to enact the following rules: * A private method in an interface is part of that interface's table of signatures. * A class implementing a private method in an interface cannot graduate its visibility (e.g. protected or public). With these rules in place, D would support NVI very naturally. I think that's a powerful paradigm that would lead to very expressive and robust interfaces. -- Apr 28 2008
d-bugmail puremagic.com wrote: Apr 28 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2051 ------- Comment #2 from kamm-removethis incasoftware.de 2008-04-28 07:16 ------- By the current D spec private functions are never virtual. I'm pretty sure that's why having a private function in an interface won't work. -- Apr 28 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2051 ------- Comment #3 from andrei metalanguage.com 2008-04-28 11:15 ------- (In reply to comment #1)d-bugmail puremagic.com wrote: Apr 28 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2051 ------- Comment #4 from andrei metalanguage.com 2008-04-28 11:27 ------- (In reply to comment #2)By the current D spec private functions are never virtual. I'm pretty sure that's why having a private function in an interface won't work. Apr 28 2008
|