Code That Says Exactly What It Means

Peter C peterc at gmail.com
Thu Oct 30 21:30:16 UTC 2025


On Thursday, 30 October 2025 at 13:20:34 UTC, Kapendev wrote:
> On Thursday, 30 October 2025 at 06:21:41 UTC, Peter C wrote:
>> And for those that argue.. well .. in Ada.. packages are the 
>> unit of encapsulation too.. so what's the big deal with D 
>> having choosing to have the module as the unit of 
>> encapsulation?
>>
>> I'd answer: it is very likely, that if Ada were designed 
>> today, in a world dominated by class-oriented programming, the 
>> designers would likely blend the two models:
>>
>>  - Keep packages as the unit of modularity.
>>  - Give types the ability to maintain their own encapsulation 
>> boundary (so invariants are truly type‑owned) - ( which is 
>> what a 'scopeprivate' like attribute .. would do).
>>
>> Then D would align with the modern 'a class maintains its own 
>> invariants' model.
>
> There is nothing modern about this. It's just a *preference* 
> thing.
> Also, did you ask the Ada devs whether they would even want 
> that? Sure, it's an old language, but that doesn't mean much.

That's where I strongly disagree.

The lessons from the Swift community is there for everyone to see 
- and learn from.

It wasn't just a matter of preference. Public by default or 
private by default, that is a matter of preference. Removing the 
concept of an encapsulated type... that is in a whole different 
ballpark.

It was the Swift programmers, not the language designers, that 
eventually got Swift corrected (from the perspective of the 
programmers) - in line with what (a majority of) programmers 
expected, and not what the designers wanted.

It's not that scopeprivate is a bad idea. It's that D doesn't 
have a majority of programmers who think its a bad idea .. and 
likely never will.

But if it does, then I'll be the first to say .."I told you so" 
;-)



More information about the Digitalmars-d mailing list