[Issue 2050] New: interfaces should allow final methods with body
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Apr 27 23:55:44 PDT 2008
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 at digitalmars.com
ReportedBy: andrei at 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.
--
More information about the Digitalmars-d-bugs
mailing list