modules
James Pelcis
jpelcis at gmail.com
Sun Apr 30 07:59:01 PDT 2006
As I understand it, the documentation is referring to the default module
name. If you felt like it, you could do something like the following:
test1.d
module blah;
private import std.stdio;
void print (char[] data) {
writefln(data);
}
test2.d
import blah;
void main () {
print("This was successful.");
}
This can confuse build though, I think.
Gabe wrote:
> I don't quite understand the module declaration at the top of source files.
> From the D website, I see that 'Modules have a one-to-one correspondence with
> source files. The module name is the file name with the path and extension
> stripped off.' So, I guess my question is: why bother? If the name of the file
> and the name of the module are the same thing, why are you (in essence) stating
> it twice? (It strikes me as a tad 'header.h'y) Wouldn't it make more sense to
> have implicit module declarations, as in Java, where 'module std' would
> represent one directory named 'std' and the name of the file simply IS the name
> of the module? Naming the file and then naming the module the same thing inside
> the file seems a tad, well, redundant. Also, isn't this why there's the
> somewhat (from my perspective) hacky 'all.d' declarations in some external
> packages? Wouldn't 'module std' and 'import std.*' be more effective solutions,
> simply relying on the compiler and PATH variables to sort out the rest?
>
> But then again, I could totally be missing something here.
> -Gabe
>
>
More information about the Digitalmars-d-learn
mailing list