Inner Modules?

Nick Treleaven nick at geany.org
Sun Feb 13 11:27:54 UTC 2022


On Saturday, 12 February 2022 at 19:37:49 UTC, forkit wrote:
> oh. the motivation for this?
>
> to not have to put your class in a separate module, just to 
> enforce private.

Another use case for this is when you want a namespace inside a 
module with other top-level declarations. This is actually done 
for `core.memory` with a hack. There is a `struct GC` with 
`@disable this();` and only static members:
https://dlang.org/phobos/core_memory.html#.GC

It would be much nicer for the docs and code if an inner module 
could be used instead:

```d
module core.memory;
...
module GC
{
   nothrow void enable();
   nothrow void disable();
   ...
}
```



More information about the Digitalmars-d mailing list