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

forkit forkit at gmail.com
Wed Jun 8 21:38:24 UTC 2022


On Wednesday, 8 June 2022 at 19:12:33 UTC, bauss wrote:
> On Wednesday, 8 June 2022 at 18:53:35 UTC, Walter Bright wrote:
>> My experience with C++ and the "friend" class concept is it is 
>> necessary for C++ because it has no notion of a module.
>>
>> D is much simplified by making the module the fence for 
>> encapsulation. C++ favors a smaller number of large files, D 
>> is designed around a larger number of small files.
>>
>> I understand that you don't prefer that approach, but I 
>> suspect if you've used "friend" classes much in C++ you'd 
>> change your mind. Most people find D's way a relief.
>
> I think there are two sides of the coin.
>
> Also I don't think it's necessarily that people have a problem 
> with how D wants it, it's just that some of us would like the 
> option to opt-out of it when needed.

+1

why is so hard for people to get this point? I don't get it.

It seems like such a simple concept -> an option to have a member 
of a class that is private to that class.

C'mon everyone. It's simple to get your head around.

There is no part of this idea that requires anyone to change what 
they currently do in D.

It's @pure opt-in.


More information about the Digitalmars-d mailing list