Why modules is so strongly limited?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 14 02:36:17 PDT 2016


On Wednesday, July 13, 2016 20:58:02 imbaFireFenix via Digitalmars-d wrote:
> Hello my friends!
> I'm new user of D language and leaarning how it works.
> I'm know C++ and trying Rust, GO and some else and now - D is the
> best language for me
>
> But I'm confused... Many coders was great work and interesting
> features, but modules is so strongly limited!!!
>
> https://dlang.org/spec/module.html
> Only one module per file.
>
> but Rust and beta VC++ can multiple file to one module! Why
> implemented this limit?
> Why modules not written as mix of C# namespace and C++
> translation unity? It will be greatly!

It's cleaner and more straightforward for modules to match up one-to-one
with files and for packages to match up one-to-one with directories. Java
does basically the same thing (though they take it even farther, since they
only allow one, public class per module), and IIRC, a number of other
languages do as well (haskell does from what I recall, and python might; I
don't remember). If we didn't do it that way, then it would be a lot harder
to figure out where all of the code for a given module was, and while some
folks may find it occasionally annoying, most of use have no problem
whatosever with modules being files and packages being directories. Overall,
it works very well.

- Jonathan M Davis



More information about the Digitalmars-d mailing list