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

Atila Neves atila.neves at gmail.com
Thu Nov 1 17:58:34 UTC 2018


On Thursday, 1 November 2018 at 16:19:57 UTC, 12345swordy wrote:
> On Thursday, 1 November 2018 at 14:17:13 UTC, Atila Neves wrote:
>> On Monday, 29 October 2018 at 23:15:58 UTC, unprotected-entity 
>> wrote:
>>> On Monday, 29 October 2018 at 15:50:56 UTC, Jonathan M Davis 
>>> wrote:
>>>>
>>> It's not (just) that I don't like it, it's that I don't like 
>>> not giving the programmer the tool to better encapsulate 
>>> their code (specifically classes) *within* a module.
>>
>> You don't need to protect code in your module from other code 
>> in your module. If you do, put them in different modules.
> That typically involves creation of files, which is not always 
> ideal if you are working with code that is considerably small.

If the code is considerably small you don't need private. You 
don't need any good engineering principles at all, use goto to 
your heart's content. It just doesn't matter.

That makes as much sense to me as introducing a keyword to 
protect a class from itself.



More information about the Digitalmars-d mailing list