modules

Gabe Gabe_member at pathlink.com
Sun Apr 30 00:49:32 PDT 2006


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