Access visibility and linkage
Seb
seb at wilzba.ch
Thu Feb 15 06:52:15 UTC 2018
On Thursday, 15 February 2018 at 06:43:52 UTC, Arun
Chandrasekaran wrote:
> I was reading through
> https://wiki.dlang.org/Access_specifiers_and_visibility#What_is_missing
>
>> [...]
>
> DMD v2.077.1 exhibits the same behavior. Is this is already
> being worked on? Or is there any plan to address this? Can this
> be fixed? If so how? If not, why not?
AFAICT it's a feature as the article correctly explains this
doesn't work well with serialization:
> Compile-time reflection, i.e. serialization libraries or
> @attribute scanners. Limiting access for __traits may forbid
> certain currently working idioms.
Use Voldemort types if you want to truly encapsulate something.
>> [...]
>
> Also, why is the default visibility of global variables at
> module level public Shouldn't they be private by default to
> provide better encapsulation guarantee (and linkage guarantee
> if the above is addressed in future)?
> From readability point of view as well, for instance, if I want
> to know all the functions "exposed" by the current module, I
> can simply grep for public.
It's a sensible default for most libraries and problems.
Simply use `private:` if you think otherwise.
More information about the Digitalmars-d-learn
mailing list