Why do private member variables behaved like protected in the same module when creating deriving class?
unprotected-entity
unprotected-entity at gmail.com
Wed Oct 31 20:44:47 UTC 2018
On Sunday, 28 October 2018 at 15:47:15 UTC, Stanislav Blinov
wrote:
> On Sunday, 28 October 2018 at 15:41:47 UTC, Neia Neutuladh
> wrote:
>
>> In D, x is private to C and any types or functions defined in
>> the same module.
>
> ...and can be accessed via reflection (.tupleof). </Pedantry>
Whenver that statement comes up, it needs to be mentioned, yet
again, that access modifiers are not a 'security' feature.
They "are a convenient design constraint, to help us structure
our applications properly." - and yes, they are convenient within
a module too (unless your module doesn't care about them - cause
then they're completely useless).
Using reflection to explicitly break open something, is not the
same as leaving it completely open in the first place (within a
module, where that is always the case).
More information about the Digitalmars-d
mailing list