How to organize using modules?
Afshin
davidnia1 at gmail.com
Mon Dec 30 22:01:18 PST 2013
Is it possible to describe modules in terms of packages (as found
in Java)?
The features that Java packages have that I can't seem to get in
D are:
1) You can have classes that are in the same package, but kept in
separate files.
2) You can import many classes using the '*' syntax.
Is this possible in D?
What I understand is that if I have ClassA and ClassB in Module1,
and I want to keep the classes in separate files, then I have to
use the following module statements:
in ClassA:
module Module1.ClassA;
in ClassB:
module Module1.ClassB;
But now it becomes cumbersome to use the classes because now I
have to import them explicitely:
import Module1.ClassA;
import Module1.ClassB;
If I wanted to use:
import Module1;
Then it seems I have to have ClassA and ClassB in the same D file.
Am I missing something?
More information about the Digitalmars-d-learn
mailing list