Static function conflicts with Non-Static?!
Jonathan M Davis
jmdavisProg at gmx.com
Sat Jun 2 01:23:50 PDT 2012
On Saturday, June 02, 2012 10:14:51 Zhenya wrote:
> I'm not sure, but it seems that this is a bug.
It's not. If nothing else, it's perfectly legal to call a static function with
an instance. e.g.
class C
{
static void func() {}
}
auto c = new C;
c.func();
So, that creates an ambiguity if a static and non-static function could have
the same name. Now, it could just assume that the instance was meant in this
case, but it doesn't work that way. It's just illegal to overload a static
function with a non-static function.
Personally, I wish that it weren't legal to call a static function with an
object and that you had to explicitly use the class, but that's not the way
that it is in D, C++, and Java (and probably the same for C#, though I'm not
sure).
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list