Adding a new design constraint to D

claptrap clap at trap.com
Tue Jun 14 10:07:49 UTC 2022


On Tuesday, 14 June 2022 at 05:43:49 UTC, forkit wrote:
>
> But the D programming language has no feature to declare such 
> an intent. So where does this leave those programmers?

It leaves 99.9% of them going "Oh OK" and carrying on programming.


> The argument has been made, that D does not need such a 
> feature, because scope is always at the module level.

The argument is this... "If you have access to the source code of 
the module then you can already muck about with the internals of 
the class, you ought to know what you're doing so adding "strict 
private" doesn't actually gain you anything.


> But it does not follow, that scope at the module level 
> eliminates the need for such a feature. That argument is not 
> logical.

It eliminates 99% of the need for it. The other 1% is a gift to 
the gods of compromise in exchange for friend access between 
classes that need it.


> Now the advantage of adding such a feature, is that it provides 
> private at the scope level for those who want or expect such a 
> feature, it provides evidence of the designers intent to 
> separate implementations from interface, and the compiler which 
> now knows the intent, can enforce that intent, at compile time.

If "People coming from Java expect X" was a good argument for 
adding X then D would just be Java.


> So the only logical outcome of this discussion, is whether the 
> benefit of adding a design constraint *option* to the language, 
> outweighs the cost of adding it to the langauge.

The onus is on you to demonstrate a genuine need for it other 
than it's just what people expect.


More information about the Digitalmars-d mailing list