On Monday, 6 June 2022 at 03:17:34 UTC, forkit wrote:
cannot have encapsulation unless it is put into a super type
(the module), all by its self (with no friends).

It can have friends - they just need to be in the same file (module). And a class without its friend is really only half a type - that's why it is better to think of the module as the new type - which contains both the interface and all interna (friends and sub-classes and @system parts that should not be visible from the outside).

That's what a file is for in general: to collect things that belong together and should be seen as a single object. It makes no sense to put other unrelated classes or functions into the same file. Especially not in a large project (which is the only case where encapsulation makes sense at all).

Reply via email to