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

bauss jj_1337 at live.dk
Wed Jun 8 10:58:09 UTC 2022


On Wednesday, 8 June 2022 at 10:49:58 UTC, Arafel wrote:
> 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

Because functions cannot be package __and__ virtual.


More information about the Digitalmars-d mailing list