|
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 2050] New: interfaces should allow final methods with body
http://d.puremagic.com/issues/show_bug.cgi?id=2050 Summary: interfaces should allow final methods with body 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 { void bar(); final void baz() { bar; bar; } } This code doesn't go through on grounds that interfaces cannot define methods with bodies. In fact, final methods don't break any laws of nature because they are not meant to be overriden and, aside from lookup, have the regime of ordinary functions. It would appear that this issue is easy to mitigate: interface Foo { void bar(); } void baz(Foo foo) { foo.bar; foo.bar; } Generally I favor free functions so I'd be happy with the above. But there are two troublesome scenarios: 1. Operators must be members 2. Sutter's NVI idiom (http://www.gotw.ca/publications/mill18.htm) can be implemented more clearly with members than with virtual functions. There are a couple of other bugs applying to NVI in D as well, that I'll post later. -- Apr 27 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2050 ------- Comment #1 from wbaxter gmail.com 2008-04-28 02:07 ------- That would open the door to the dreaded diamond pattern. You'd just have the compiler generate ambiguity errors in those cases I suppose? -- Apr 28 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2050 ------- Comment #2 from andrei metalanguage.com 2008-04-28 02:21 ------- (In reply to comment #1)That would open the door to the dreaded diamond pattern. You'd just have the compiler generate ambiguity errors in those cases I suppose? Apr 28 2008
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=2050 ------- Comment #2 from andrei metalanguage.com 2008-04-28 02:21 ------- (In reply to comment #1)That would open the door to the dreaded diamond pattern. You'd just have the compiler generate ambiguity errors in those cases I suppose? Apr 28 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2050 aarti interia.pl changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aarti interia.pl ------- Comment #3 from aarti interia.pl 2008-04-28 03:56 ------- It seems that same rationale applies to static functions in interfaces. Currently below code doesn't work, as static functions can not have body in interface. --- int a; interface A { static int number() { return a; } } --- Current situation is just plainly wrong as it is possible to put static functions into interfaces and it is not possible to use them at all - linker error is emitted during compilation (what is understandable as static functions are not virtual). -- Apr 28 2008
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=2050 aarti interia.pl changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aarti interia.pl ------- Comment #3 from aarti interia.pl 2008-04-28 03:56 ------- It seems that same rationale applies to static functions in interfaces. Currently below code doesn't work, as static functions can not have body in interface. --- int a; interface A { static int number() { return a; } } --- Current situation is just plainly wrong as it is possible to put static functions into interfaces and it is not possible to use them at all - linker error is emitted during compilation (what is understandable as static functions are not virtual). Apr 28 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2050 ------- Comment #6 from andrei metalanguage.com 2008-04-28 11:12 ------- (In reply to comment #5)d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=2050 ------- Comment #2 from andrei metalanguage.com 2008-04-28 02:21 ------- (In reply to comment #1)That would open the door to the dreaded diamond pattern. You'd just have the compiler generate ambiguity errors in those cases I suppose? Apr 28 2008
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=2050 ------- Comment #6 from andrei metalanguage.com 2008-04-28 11:12 ------- (In reply to comment #5)d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=2050 ------- Comment #2 from andrei metalanguage.com 2008-04-28 02:21 ------- (In reply to comment #1)That would open the door to the dreaded diamond pattern. You'd just have the compiler generate ambiguity errors in those cases I suppose? Apr 28 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2050 ------- Comment #7 from andrei metalanguage.com 2008-04-28 11:14 ------- (In reply to comment #3)It seems that same rationale applies to static functions in interfaces. Apr 28 2008
|