Is this expected? default to public members in private class
Dan Olson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon May 4 08:37:55 PDT 2015
ketmar <ketmar at ketmar.no-ip.org> writes:
> On Sun, 03 May 2015 18:07:20 -0700, Dan Olson wrote:
>
>> It seems a private class or struct defaults to public members. Just
>> curious if this is intended. I would have expected private all the way
>> down unless overriden.
>
> i bet it is intended. protection of struct/class members is independed of
> protection of struct/class itself. this is good for code consistency: no
> changing of outer protection flags can alter struct/class inner
> machinery. so if you changed your mind about protection level of some
> global things, you shouldn't unnecessary "fix" your code in completely
> unrelated places.
Thanks ketmar, that makes sense. I am in midst of adding an option to
have dscanner skip private/package declarations when emitting etags (new
--etags option) and I want to match what the D lang spec would say is
private (if it did say). For now I have to reverse engineer based on
compiler and forums, but don't want to mimic a compiler bug.
More information about the Digitalmars-d-learn
mailing list