really why module declarations?

XavierAP via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 26 13:51:01 PDT 2017


I've perused both the spec[1] and Andrei's book, and I the idea I 
get is that module declarations are optional, recommended only in 
case of file names not being valid D names. But in the community 
(and Phobos) I see it's strongly recommended and used throughout.

What's the reason? If the declaration overrides the path 
(provided the file is found) rather than enforcing path 
consistency by outputting a compile error, then what's the 
benefit of module declarations, if we have to be disciplined to 
keep it consistent with paths anyway?

I'm busy starting my first big multi file D project, thanks for 
any feedback!


[1] https://dlang.org/spec/module.html#ModuleDeclaration


More information about the Digitalmars-d-learn mailing list