Is it legal to have physical package structure not corresponding to logical one? How to generate .di from that?

Adam D. Ruppe destructionator at gmail.com
Mon Sep 16 13:13:50 UTC 2019


On Monday, 16 September 2019 at 07:02:04 UTC, Max Samukha wrote:
> Is the spec wrong?

Well, sort of, your code is perfectly legal and has worked since 
the beginning of D. The thing in the spec is referring to the 
assumption the compiler uses to find files not explicitly 
referenced on the build command.

import p1.p2.a;

assumes p1/p2/a.di or p1/p2/a.d.

but if you reference the module, `dmd a.d whatever/b.d`, it will 
not look up based on this assumption anymore.

> If yes, how does one create an import tree from the structure 
> like that?

I don't think dmd will create them automatically though, dmd -H 
kinda sucks, it used to just slap them down flat, now I think it 
copies the src structure, but it doesn't consider the module 
names (but it should!). You'll have to sort them yourself.

Also note the -mv option to dmd

-mv=package.module =
     Use path/filename as the source file for package.module. This 
is used when the source file path and names are not the same as 
the package and module hierarchy. The rightmost components of the 
path/filename and package.module can be omitted if they are the 
same.


which explicitly overrides the automatic assumption above, so 
import can look up any file.


More information about the Digitalmars-d-learn mailing list