Code That Says Exactly What It Means

Paul Backus snarwin at gmail.com
Wed Oct 29 16:18:22 UTC 2025


On Wednesday, 29 October 2025 at 13:55:42 UTC, jmh530 wrote:
> You say it's a "major change to the language". Is it really? I 
> thought `private(this)` was added to Open D without much 
> difficulty.

It's a change to the grammar, which means that all parser-based 
tooling (DCD, DScanner, serve-d, etc.) would need to be updated 
to support it.

> It's also occasionally more difficult to split up code into 
> multiple modules. For instance, what if you are prototyping 
> something in run.dlang.io (impossible I think in this case)

You can actually have multiple modules on run.dlang.io, using the 
following syntax:

     --- lib.d
     module lib;

     int fun() { return 42; }

     --- app.d
     module app;

     import lib;

     void main()
     {
         assert(fun() == 42);
     }

> With respect to the secondary arguments:
> 1) On the mental complexity budget issue, I don't view that as 
> a big issue as it is a convenient extension of the protection 
> modifiers. `protected` and `package` are probably more 
> confusing than this.

Managing overall language complexity is the #1 challenge in 
language design. If you don't take this seriously, your language 
ends up like C++ or Perl--a huge mess that nobody really 
understands completely. (You could argue that D has already 
crossed this line, but even if that's true, it doesn't mean we 
should make it worse.)

Even features that are small and simple in isolation can add up 
to an enormous amount of complexity if you accumulate too many of 
them (see: Perl). So the fact that this individual feature is 
relatively simple is not a strong counterargument.



More information about the Digitalmars-d mailing list