Introspecting a package for submodules

Adam D. Ruppe destructionator at gmail.com
Tue Aug 25 00:09:38 UTC 2020


On Monday, 24 August 2020 at 22:32:52 UTC, Anonymouse wrote:
> How do I do this? (Is there some other way?)

Not really a way. A package doesn't quite exist in D; there is no 
formal construct that is a package and has a defined list if 
stuff.

It is just whatever modules are compiled in that happen to have 
the same starting bits in their name.

If you made a file and put `module std.algorithm.mystuff;`, the 
language would treat it exactly the same way as if it was the 
Phobos authors did... the two files have no connection beside 
name, and need not even be compiled together, so no compile-time 
introspection could ever list it all.

What some people do is have a pre-build step that scans the files 
and pulls the module names out ahead of time, then you can 
organize them by name too and sort it that way. But the compiler 
isn't really of any help.


More information about the Digitalmars-d-learn mailing list