Can call static method with null reference

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


On Monday, June 24, 2013 11:51:52 Steven Schveighoffer wrote:
> My suggestion to fix this has always been: only allow static calls on
> instance variables via opt-in. e.g.:
> 
> class InfiniteRange
> {
> static bool empty() { return false; }
> alias InfiniteRange.empty this.empty; // just an example
> }
> 
> This allows all the benefit, but none of the bug-prone problems.

I would _love_ to make that fix, but the trick is convincing Walter (since the 
chance risks breaking code). Or maybe it's one of those things that convincing 
Kenji to implement it would be enough, since it could sneak in that way? I 
don't know. Regardless, I think that we'd be better off if we made the change.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list