Static function conflicts with Non-Static?!

Jonathan M Davis jmdavisProg at gmx.com
Sat Jun 2 10:55:57 PDT 2012


On Saturday, June 02, 2012 08:41:17 H. S. Teoh wrote:
> On Sat, Jun 02, 2012 at 01:23:50AM -0700, Jonathan M Davis wrote:
> [...]
> 
> > 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).
> 
> [...]
> 
> I've always been of the opinion that static methods should _only_ be
> callable via the class name. If an instance is not needed, then it
> shouldn't be used in the first place. Allowing the use of a class
> instance where it's not needed is needlessly confusing and prevents
> legal overloading of static methods vs. non-static methods.

The trick is getting Walter to agree. I don't know how entrenched his thinking 
on the matter is, but changing it _would_ be a breaking change, which makes it 
harder to convince him to make the change, even if he nominally agrees. And, 
of course, it's easier if someone actually goes and makes the required changes 
to the compiler and submits a pull request, but someone would obviously have 
to take the time to do that.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list