Static function conflicts with Non-Static?!
Namespace
rswhite4 at googlemail.com
Sat Jun 2 01:35:18 PDT 2012
On Saturday, 2 June 2012 at 08:24:16 UTC, Jonathan M Davis wrote:
> 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
Strange thing.
But I understand, thanks. :)
More information about the Digitalmars-d-learn
mailing list