Working with modules

Dmitry Olshansky dmitry.olsh at gmail.com
Fri Feb 15 01:58:36 PST 2013


15-Feb-2013 13:51, Colin Grogan пишет:
[snip]

> This is where my problem occurs. To illustrate:
> $PROJHOME
>      |-/src
>          |- utils
>               |- Logger.d
>               |- Properties.d
>               |- SSHTool.d
>          |- engine
>
> I want to put Logger.d, Properties.d and SSHTool.d into the module
> 'utils'. However, D's module system wont allow that, keeps throwing back
> errors to me saying 'utils' is conflicting (or something similar, cant
> remember the exact error).
> So, I've done a bit of reading, and found out that I should put all
> those classes into once source file, and put that file in the module
> 'utils'.

> Now, thats all fine and dandy, but I expect by the end of this
> experiment I will have quite a lot of utility classes and I really dont
> want them all in one source file. It becomes unwieldy imo.
>
> Does anyone here have any alternatives for me so that in my 'engine' or
> 'main' classes I can simply write:
>
>      import utils;

Another way is to create utils/_.d file that contains:

public import utils.Logger;
public import utils.Properties;
public import utils.SSHTool;

and import it like this:
import utils._;


The other popular name for this module is 'all'.
>
> and still have my source files neatly laid out in manageable chunks?

Yeah, community at large wants a cleaner way to do this. It just wasn't 
sorted out yet:
http://wiki.dlang.org/DIP14
http://wiki.dlang.org/DIP15

>
> Thanks in advance...


-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list