Working with modules

Colin Grogan grogan.colin at gmail.com
Fri Feb 15 02:31:40 PST 2013


On Friday, 15 February 2013 at 10:01:35 UTC, Jonathan M Davis 
wrote:
> On Friday, February 15, 2013 10:51:00 Colin Grogan wrote:
>> Does anyone here have any alternatives for me so that in my
>> 'engine' or 'main' classes I can simply write:
>> 
>>      import utils;
>> 
>> and still have my source files neatly laid out in manageable
>> chunks?
>
> The only way that you can have a single import which imports 
> multiple modules
> is if the module that you're importing publicly imports the 
> other modules. And
> there is no way to do something like
>
> import utils.*;
>
> And remember that modules always correspond to files, and 
> packages correspond
> to folders, so there's a one-to-one correspondance between what 
> you'd import
> and what you'd put in the file system (unless you use public 
> imports to make it
> so that importing a module imports stuff from outside that 
> module).
>
> - Jonathan M Davis

Ah, ok.

So, I have my structure like so:

$PROJHOME
     |-src
        |-utils
           |- Logger.d // contains "module utils.Logger"
           |- Props.d //  contains "module utils.Props"
           |- utils.d //  contains "module utils;
                                    public import utils.Logger, 
utils.Props;"

Then, i just 'import utils' in my code.

Or would I have to have Logger.d in a directory called 
src/utils/Logger/Logger.d to be able to declare the module 
'utils.Logger'?


More information about the Digitalmars-d-learn mailing list