Using closure in function scope to make "real" private class members

Arafel er.krali at gmail.com
Wed Jun 8 10:49:58 UTC 2022


On 8/6/22 12:00, bauss wrote:
> 
> I completely agree. I really hate the current design, because I have 
> been in situations where I have separated classes because they needed 
> private fields, but then later I actually needed some of the fields 
> shared and had to share those fields public.

Out of curiosity, why wasn't `package` or eventually `package(foo)` [1] 
an option? It seems to have been designed for this very purpose.

Of course the classes could be in packages with no common ancestor, but 
then it would perhaps be worth questioning how so closely coupled 
classes end up so far away in the hierarchy.

[1]: https://dlang.org/spec/attribute.html#VisibilityAttribute


More information about the Digitalmars-d mailing list