Reason for mypackage/package.d instead of mypackage.d

Jonathan Marler via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 10 13:25:30 PST 2014


I was perusing a PR for phobos where std/range.d was split into 
submodules and std/range.d was moved to std/range/package.d

I was wondering why a package module had to be called "package.d" 
instead of just being the package name.  For example, instead of 
moving std/range.d to std/range/package.d, why doesn't modifying 
std/range.d to contain the public imports of the submodules work 
just as well?

My first thought was that maybe it let's the compiler know that 
all "package" modifiers are visible to all the modules in the 
same package, and the only way the compiler knows about what 
modules are in a package are if they are imported in the 
package.d file...is this one of the reasons?  Also are there 
other reasons?  Thanks in advance.


More information about the Digitalmars-d-learn mailing list