Can call static method with null reference

Jonathan M Davis jmdavisProg at gmx.com
Mon Jun 24 12:50:40 PDT 2013


On Monday, June 24, 2013 19:13:45 Jesse Phillips wrote:
> On Sunday, 23 June 2013 at 10:09:39 UTC, Jonathan M Davis wrote:
> >> Also I don't know why I should call static methods from an
> >> instance. What's the purpose?
> > 
> > It's stupid and pointless as far as I can tell, but I believe
> > that C++, Java,
> > C#, and D all do it, so as stupid as it is, it's a common
> > stupidity
> 
> Java prevents it, I'm pretty sure C# picked that up from Java.
> (Unless Java has changed since 1.5)

I was certain that I'd checked it at one point and determined that Java 
allowed it, but I could be wrong. It's certainly better if I am, since it's a 
bad design decision to allow static functions to be called on instances IMHO.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list