Why do private member variables behaved like protected in the same module when creating deriving class?
Steven Schveighoffer
schveiguy at gmail.com
Fri Oct 26 21:05:56 UTC 2018
On 10/26/18 3:28 PM, 12345swordy wrote:
> On Friday, 26 October 2018 at 18:57:00 UTC, Neia Neutuladh wrote:
>> On Fri, 26 Oct 2018 18:16:38 +0000, 12345swordy wrote:
>>> [...]
>>
>> D's `private` within a module is identical to Java's `private` within
>> a class and its nested classes. The following is valid Java:
>>
>> [...]
>
> Again I am referring to classes in the module not the module itself.
Classes in the module are in the module. So any classes in the module
*are* the module itself.
What it seems like you are saying is that you want non-derivatives to
still be able to access private variables, but derivative classes are
forbidden? Nothing personal, but this really doesn't make a lot of
sense. I feel like maybe there is a misunderstanding.
Note that the lack of ability to encapsulate data in classes or structs
within a module has been discussed here a lot. It's not going to change,
however, as it comes down to a deliberate choice between encapsulation
and ease of implementation.
-Steve
More information about the Digitalmars-d
mailing list