Skip to main content
4 events
when toggle format what by license comment
Mar 1, 2017 at 11:31 comment added Phill W. Yes, the compiler /could/ but why should it? Passing such a pointer essentially reduces it to an instance method. Your stipulation that it is only private methods that could do this is moot - Reflection technologies make /all/ methods accessible - private or not - making this an even more risky proposition. Our Friends in Redmond have gone in the other direction; their languages raise a warning if you try to call a static method against an object instance (and not the class itself).
Feb 28, 2017 at 18:06 comment added Loren Pechtel You miss my point. If it's called from within the class the compiler could pass an instance pointer like it does when it's not a static class. The problem comes if it's called from elsewhere--which means private static methods could access instance data (albeit by internally basically ignoring the static.)
Feb 28, 2017 at 11:53 comment added Phill W. I disagree. A static method cannot access instance data because instance data must be accessed via an instance of the object and the static method is not associated with any given instance (but with the class definition).
May 2, 2014 at 21:00 history answered Loren Pechtel CC BY-SA 3.0