static and protection | FQ names and protection

Bruno Medeiros daiphoenixNO at SPAMlycos.com
Fri Mar 3 03:15:05 PST 2006


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.
 >
 >


Bruno Medeiros wrote:
> Jarrett Billingsley wrote:
>>
>> And the problem that the OP posted is most likely related to the 
>> "protection attributes mean nothing if you use a fully qualified name" 
>> bug.
>>
> No, I think it is more likely related to the bug of protection 
> attributes only working for instance members, and no other entities. For 
> example, protection attributes also don't work for classes or structs. 
> As in:
> 
>   private class Foo {  // 'private' is effectless
>     ...
>   }
> 

Anyway, I've commented and reported about this issue before, but didn't 
get Walter's opinion on it, so I don't know if he considers this a bug 
or not. Anyone knows about this? (well, Walter at least does for sure)
I can already see by the spec ( 
http://www.digitalmars.com/d/attribute.html ) that protection is 
currently only member-centric, but should we or not change (improve, 
IMO) this behavior?

I also would like to know about the issue of using fully qualified names 
ignores protection attributes:

   moduleFoo.privateFunc() // Compiles ok, shouldn't

Is it also a bug or not? (should well damn be!)

(Hum, starting to think we could improve our way of tracking bugs and 
design issues)

-- 
Bruno Medeiros - CS/E student
"Certain aspects of D are a pathway to many abilities some consider to 
be... unnatural."



More information about the Digitalmars-d mailing list