On Thursday, 18 July 2013 at 07:43:33 UTC, Jonathan M Davis wrote:
On Thursday, July 18, 2013 09:25:46 JS wrote:
In any case, the real question I have is: Does dmd require each
directory for each module to be included by -I? Or is the base
directory good enough and package resolution will get at the sub
directories?

The base directory of each package hierarchy must be passed to dmd with -I. So, if you have the module abc.foo.bar, then dmd must have been passed the directory that abc is in. A module's fully qualified name is its directory hierarchy, and dmd is always looking for the base of the hierarchy, so you give it each directory which is the root of a package hierarchy. If you have abc.foo.bar, and you passed it the abc or abc/foo, it would then effectively be
looking for abc/abc/foo/bar.d or abc/foo/abc/foo/bar.d.

- Jonathan M Davis


using All instead of package as the name worked really well, I can easily chain imports and each module can import the root to import the whole library.

e.g.,
lib/All.d
lib/modules*.d
lib/dir?/.../dir?/modules*.d

each module only has to import All to get access to the whole library. Only the final directories need to import each module. Each internal directory just has to import the All.d's of each subdirectory and any modules in the same directory.

Seems to work really well and very simple to update and include various parts of the library.

e.g.,
/all.d
/a.d
/dir/all.d
/dir/b.d

all.d:
module all;
public import a;
public import dir.b;

/dir/all.d
module dir.all;
public import dir.b;

(I do have my lib partitions for different libraries I have something like import mylib.all)

essentially all acts like *. e.g., import dir.*; is the same as import dir.all; (except * would automatically import everything for you making life easier).



Reply via email to