Import all?

JS js.mdnq at gmail.com
Wed Jul 17 23:45:25 PDT 2013


On Wednesday, 17 July 2013 at 17:51:15 UTC, Jonathan M Davis 
wrote:
> On Wednesday, July 17, 2013 11:34:56 JS wrote:
>> Is is possible to import all modules using something import
>> a.b.*;?
>> 
>> I'd like to partition some modules up into smaller pieces to
>> simplify modification(reduce scrolling) but, of course, this
>> increases the number of imports drastically.
>
> This has been implemented in git master:
>
> http://wiki.dlang.org/DIP37
>
> - Jonathan M Davis

Thanks, I've updated the compiler to 2.063.2 and made my 
hierarchy like

lib/package.d
lib/mod.d
lib/dir1/package.d
lib/dir1/a.d
lib/dir1/b.d
lib/dir2/package.d
lib/dir2/c.d

each package.d file publically imports all sub packages(by 
chaining package imports and importing same directory modules):

lib/package.d:
module Package;
public import mod.d;
public import dir1.Package;
public import dir2.Package;

lib/dir1/package.d;
module dir1.Package;
public import dir1.a;
public import dir2.b;


etc....

This should allow me to import any resolution I need. e.g., if I 
want the whole library I just import lib/package.d.


When I do this dmd can't find my module files.

I have only included the root dir(lib) in sc.ini, hopefully I do 
not need to include every single subdirectory in lib for it to 
work ;/ ? (this would be better to be auto generated)



More information about the Digitalmars-d-learn mailing list