modules

Derek Parnell derek at psych.ward
Sun Apr 30 01:32:36 PDT 2006


On Sun, 30 Apr 2006 17:49:32 +1000, Gabe <Gabe_member at pathlink.com> 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

...

> Naming the file and then naming the module the same thing inside
> the file seems a tad, well, redundant.

In once sense it is redundant. The module name is always the file name so  
what purpose does the 'module' statement serve? The only thing I can come  
up with is that is forces a naming convention on coders wanting to use  
your module. If you didn't have the module statement it means that you can  
rename the file or move it another package, but that would cause linker  
problems with libraries that were expecting specific file and package  
names. By having the module statement explicitly encoded, you are helping  
to keep references to your module consistent.

I'm not saying this is a good or bad thing, I'm just pointing out my  
persepective on trying read Walter's mind.

-- 
Derek Parnell
Melbourne, Australia



More information about the Digitalmars-d-learn mailing list