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

bauss jj_1337 at live.dk
Wed Jun 8 10:00:08 UTC 2022


On Wednesday, 8 June 2022 at 09:57:49 UTC, forkit wrote:
> On Wednesday, 8 June 2022 at 09:38:24 UTC, Ola Fosheim Grøstad 
> wrote:
>> On Wednesday, 8 June 2022 at 09:34:09 UTC, forkit wrote:
>>> Walter has his firm view. I have mine.
>>
>> Sure, your viewpoint would make sense for D3, but then there 
>> would be many such adjustments to make.
>>
>> To make all those adjustments in D2 with no breaking change 
>> would @lead @to @a @mess.
>
> I still don't get it.
>
> I'm not advocating for my 'perfect world view' for D.
>
> just: private(this)
>
> That is not a breaking change. It would purely opt-in. Everyone 
> gets what they want (except those who don't want any change).

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.

So either you have to share all fields as friends or you share 
none.

It's too black/white.


More information about the Digitalmars-d mailing list