Code That Says Exactly What It Means
Walter Bright
newshound2 at digitalmars.com
Tue Oct 28 08:01:40 UTC 2025
On 10/28/2025 12:21 AM, Peter C wrote:
> Without appropriate scope rules, you can't enforce that boundary, and you lose
> encapsulation - and encapsulation is the foundation of abstract data types.
>
> Then, the distinction between interface and implementation collapses.
>
> Then, the type's internal rules are meaningless - the abstraction collapses, the
> type becomes harder to reason about, everything becomes global, its internal
> state leaks into the rest of the module, breaking any guarantees that the type
> is supposed to enforce.
>
> Without scope, your type just becomes a bags, that anyone can poke into,
> undermining abstraction, modularity, and reliability.
Sure, it does mean a change in layout from other languages. But the capability
is there.
The boundary is at the module level. The "friends" are the other functions in
the module. If they are not actually friends, they shouldn't be in that module.
It's entirely under the programmer's control.
As for the distinction between interface and implementation, that can also be
done with .di files. The 'i' in .di stands for "interface".
More information about the Digitalmars-d
mailing list