Overloading static methods
Jonathan M Davis
jmdavisProg at gmx.com
Mon Aug 29 10:47:15 PDT 2011
On Monday, August 29, 2011 07:44 Steven Schveighoffer wrote:
> My opinion is that static methods should *not* be callable from an
> instance, you should need typeof(instance).staticMethod. The current
> allowance is misleading.
Yeah. I don't know why it's allowed. I think that C++, Java, and C# all allow
it too, but I've always thought that it was a bad idea in all of those
languages. I don't see a problem being able to call a static method inside of
its class without giving the class name (if you had both a static and non-
static method with the same name, then you could simply require that either
the type name or this be use), but it strikes me as very lax to allow a static
method to be called with an instance. That's definitely one of the little
things that I'd love to see changed. It's not the end of the world if it
isn't, but I see no cons to changing it other than the possibility of breaking
code (which was arguably bad code to begin with).
- Jonathan M Davis
More information about the Digitalmars-d
mailing list