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

Dom Disc dominikus at scherkl.de
Mon Jun 6 11:45:31 UTC 2022


On Monday, 6 June 2022 at 02:35:11 UTC, forkit wrote:
> On Monday, 6 June 2022 at 01:23:41 UTC, forkit wrote:
>>
>
> when your boss isn't really your friend:
>
> // ----
>
> module test;
> @safe :
>
> class Employee
> {
> }
>
> class Boss
> {
> }
>
Now that is real nonsense! Why should those two classes ever be 
within the same file?!?

Not everything is a friend - only what is in the same file! And 
unlike C++ you can have friends *only within the same file* and 
not also in whatever file belonging to some other developer.
Yes, unlike in Java you can have more than one class or other 
stuff in one file. But you should only put things in one file 
that really belong together (need access to implementation 
details). And that is really easy to keep under control. In my 
opinion much easier than in C++.




More information about the Digitalmars-d mailing list