| |
 | Posted by Peter C in reply to Walter Bright | Permalink Reply |
|
Peter C 
Posted in reply to Walter Bright
| On Tuesday, 28 October 2025 at 08:37:46 UTC, Walter Bright wrote:
> On 10/27/2025 11:47 PM, Peter C wrote:
>> The internal state of this type, in D, 'automatically' leaks into the rest of the module.
>
> Yes. If you want to hide the internals of a class, put it in its own module. The "friends" then can no longer access the internals.
>
>
> > So what's the problem then?
>
> Every feature adds complexity. At some point, the language becomes unwieldy, where nobody knows the entire language, and people use only islands of it (see C++). Maintaining a language is always a battle with complexity. Having too many ways to accomplish the same goal is not very desirable.
>
> Your proposal does indeed have merit. But is it a big enough to justify a new keyword, and more documentation? The more pages a language spec has, the fewer people will read it. People love languages that can do a lot with very few pages. You could learn C in an hour reading K+R. I remember when Go was introduced and people loved that they could learn Go in just one lecture.
>
> It needs more to justify it.
>
> P.S. The major driver of the new "editions" feature is to enable us to remove features that do not carry their weight, and that have easy alternatives. It's not that they are useless features. It's just that features should have a big impact. For example, Manu and Timon convinced me that placement new would have a substantial impact on what could be done with D.
>
> P.P.S. I do appreciate the time you took to present your proposal. You've thought it out well. Thank you!
Your position is clear, and I won't push it further.
When a programming language actively and intentionally prevents me from being explicit about how the members of my class can be accessed, the programming language becomes irrelevant to me.
Taking away a tool that millions of programmers use, it not going to get D the audience it 'supposedly' desires.
I can't even do this in D!
// Compile-time visibility tests
unittest
{
auto acc = new Account(5, "Eve", 400.0, "tok5");
// Allowed:
static assert(__traits(compiles, acc.getBalance()));
// Forbidden (scopeprivate):
static assert(!__traits(compiles, acc.balance));
static assert(!__traits(compiles, acc.authToken));
}
I am very fortunate being a C# programmer, as I do not need to seek a successor language ;-)
Good luck with the future of your language.
|