static and protection

David Medlock noone at nowhere.com
Thu Mar 2 08:32:55 PST 2006


Tony wrote:

> "Hasan Aljudy" <hasan.aljudy at gmail.com> wrote in message 
> news:du4ulf$1hpp$1 at digitaldaemon.com...
> 
>>Kyle Furlong wrote:
>>
>>>John C wrote:
>>>
>>>
>>>>It appears that protection attributes on static class methods don't get 
>>>>recognised. This compiles without errors:
>>>>
>>>>    module stuff;
>>>>
>>>>    class Visible {
>>>>        private static void hidden() {}
>>>>    }
>>>>
>>>>    -----8<-----
>>>>    module program;
>>>>
>>>>    import stuff;
>>>>
>>>>    void main() {
>>>>        Visible.hidden();
>>>>    }
>>>>
>>>>An error is issued if hidden() is at module level. I sometimes feel that 
>>>>classes are second-class citizens in D.
>>>>
>>>
>>>This protection stuff is rediculous, any modern OO language needs to 
>>>handle these things well.
>>
>>Yeah, and the implicit module friendship is rediculous too!!! The whole 
>>C++ friend concept is rediclous.
> 
> 
> This is an issue that has been raised at least once before:
> 
> http://www.digitalmars.com/d/archives/digitalmars/D/23420.html
> 
> I believe that anything which violates encapsulation should be explicit.
> 
> For this reason, if a friendship level/type of access is required then an 
> explicit friend qualifier should be introduced.
> 
> This should also serve to make the C++ crowd happier.
> 
> Tony
> Melbourne, Australia
> tonysZ-mailboxZ at hotmailZ.com  (remove the Zs)
> 
> 
> 
Disclaimer: the OP code seems to be a bug, I am not contradicting that.

Each time I hear things like this I always ask for specific pragmatic 
examples of strict protection benefits outside of simple namespace-clash 
issues(which also mean IDE code completion).

I've yet to see a good example in which strict protection attributes 
prevented any defects.  Thus far this is a sky-is-falling issue, with 
very little real practical evidence.

Its frankly ridiculous to assume that a programmer working on a source 
file(a module) would be tripped up in his own classes because one was 
private and another was not.  If you cant handle a few classes in one 
source file, I question your programming expertise.

This seems like OOP-purism versus pragmatism.
I hope Walter keeps "all module classes can see each other".

-DavidM

"Wherever there is modularity there is the potential for 
misunderstanding. Hiding information implies a need to check 
communication." - Alan Perlis




More information about the Digitalmars-d mailing list