Why do private member variables behaved like protected in the same module when creating deriving class?

12345swordy alexanderheistermann at gmail.com
Fri Oct 26 22:42:42 UTC 2018


On Friday, 26 October 2018 at 22:23:04 UTC, Laurent Tréguier 
wrote:
> On Friday, 26 October 2018 at 22:01:42 UTC, 12345swordy wrote:
>> [...]
>
> Then I don't know why the fact that we have protected means 
> that the way private behaves is wrong.
>
> Anyway, I regret even partaking in this thread and I'll stop 
> here, because from what I see:
> You would like private to be visible only in the class it was 
> declared in, and nothing else. Instead it's visible from 
> everything in the module (including, indeed, the derived 
> classes). As others have pointed out, it's precisely said in 
> the docs that private is about modules and not classes.
>
> It's not going to change as it would break code; if you have an 
> idea of how to improve this, write a DIP like the one you 
> started with nested modules, and present it here on the forum 
> if you want people's opinion.

You are right, I am better off continuing writing the dip about 
nested modules then argue ad nauseam about this.


More information about the Digitalmars-d mailing list