Code That Says Exactly What It Means
Alexandru Ermicioi
alexandru.ermicioi at gmail.com
Tue Oct 28 22:51:35 UTC 2025
On Tuesday, 28 October 2025 at 22:16:19 UTC, Peter C wrote:
> One side of the argument is: If you put related types in the
> same module, they should own each other.
>
> I say no - actually, I put them in the same module because they
> needed to collaborate much more closely than they would be able
> to if they were not in the same module. But they certainly do
> not need to own each other.
>
> I have not seen any valid argument, for why 'they should own
> each other'.
Then use packages, not modules, and you'll get the properties you
want. Have modules encapsulate a single type with friends
instead, or a set of overly friendly types not privy to messing
with each one around behind the back of other colleagues (types)
in the code.
You can then have package act as a module when imported somewhere
else.
Over-fixating on why you cant have it all in a single module will
only lead to unnecessary frustration (seen it here before).
Best regards.
More information about the Digitalmars-d
mailing list