digitalmars.D - implement abstract method requires override
- =?UTF-8?B?Ikx1w61z?= Marques" (34/34) Nov 09 2013 Why do abstract methods need to be implemented with override,
- =?UTF-8?B?Ikx1w61z?= Marques" (17/25) Nov 09 2013 Ignore the abstract in the interface, it was a copy-paste bug,
Why do abstract methods need to be implemented with override,
when interfaces don't? E.g.:
class X
{
abstract void foo();
}
class Y : X
{
override void foo() {}
}
vs
interface X
{
abstract void foo();
}
class Y : X
{
void foo() {}
}
This is a bit of a problem for a design I'm doing with
template/mixin magic, making it a bit less magical. If you don't
want to change this, would you consider at least providing some
kind of pragma / attribute to work around it? E.g.
class X
{
pragma(nooverride, foo); // this or the following
nooverride abstract void foo(); // ugly OK, X is hidden
for user
}
class Y : X
{
void foo() {}
}
Thanks! :-)
Nov 09 2013
On Sunday, 10 November 2013 at 02:32:18 UTC, Luís Marques wrote:
interface X
{
abstract void foo();
}
class Y : X
{
void foo() {}
}
Ignore the abstract in the interface, it was a copy-paste bug,
although it seems to make no difference.
BTW, for completeness, I'll clarify that my exact situation is a
bit more roundabout:
interface I
{
void foo();
}
class X : I
{
abstract foo;
}
class Y : X
{
void foo() {}
}
Nov 09 2013








=?UTF-8?B?Ikx1w61z?= Marques" <luis luismarques.eu>