Should protection attributes disambiguate?

Peter Alexander peter.alexander.au at gmail.com
Tue Jun 21 02:57:54 PDT 2011


On 21/06/11 3:45 AM, Nick Sabalausky wrote:
> Isn't visibility a form of access?
>
> Regardless, I think it's clear that the whole point of a private "access"
> modifier is to make things *private* and safely encapsulated. The current
> situation clearly breaks this. And since visibility without access is
> useless, I don't see any reason to even get into the subtle semantics of
> "visibility" vs "access" at all.

It does break the idea of encapsulation a little, but we have to 
consider the side effects:

As Jonathan says, it's possible that someone could try to use a private 
symbol and instead get a public symbol from another module. Depending on 
the situation, this could introduce subtle incorrect behavior that is 
difficult to detect. It's rare, but it could happen.

You rightly argued the other way that someone could add a private 
symbol, which then causes user code to fail to compile due to a 
ambiguity. That sucks, but it is just an inconvenience that is easily 
solved by qualifying usage of the symbol. There is no possibility of 
subtle, difficult-to-detect behavior.

I'm kind of on the fence with this. There's definitely merit to both 
sides of the argument.




More information about the Digitalmars-d mailing list