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

Laurent Tréguier laurent.treguier.sink at gmail.com
Fri Oct 26 22:23:04 UTC 2018


On Friday, 26 October 2018 at 22:01:42 UTC, 12345swordy wrote:
> On Friday, 26 October 2018 at 21:46:27 UTC, Laurent Tréguier 
> wrote:
>> On Friday, 26 October 2018 at 21:42:37 UTC, 12345swordy wrote:
>>> ...Did you read the other post that I made before you made 
>>> that reply?
>>>
>>> I swear I am repeating myself ad nauseam.
>>
>> You simply seemed to be implying that private had the same 
>> effect as protected, which isn't the case.
> ... How can I make my self any more clear here!? When I say y 
> behaves like x it I don't means y is exactly the x! Nor does it 
> imply that!

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.


More information about the Digitalmars-d mailing list