static and protection

Tony ignorethis at nowhere.com
Thu Mar 2 00:11:15 PST 2006


"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)






More information about the Digitalmars-d mailing list