.d files without a module statement? Required to be absent?

WhatMeWorry kheaser at gmail.com
Sat Nov 14 17:55:13 UTC 2020


I was poking around the dmd code just to "learn from the best" 
and I came across some files that ended with the .d extension 
which did not have the module statement. (I was under the naive 
impression that all .d files must have a module statement)

However, in the directory:

https://github.com/dlang/dmd/blob/master/samples

I can see many examples where this is not the case. Most of them 
have things like Windows or C structures or calls, etc.

In stark difference, there is

https://github.com/dlang/dmd/tree/master/src/dmd/backend

where all its files seem to have file name = module name strictly 
enforced.

So I guess my question is when is the module statement required?  
Are they recommended but not essential?  Maybe some "Best 
Practices" notation?

the spec sasy "Modules automatically provide a namespace scope 
for their contents..." so maybe my question becomes, when are 
namespace scopes required to be present or required to be absent?




More information about the Digitalmars-d-learn mailing list