Scope of D packages
Jacob Carlborg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Dec 19 01:58:24 PST 2015
On 2015-12-19 00:20, Jakob Jenkov wrote:
> I'm coming from Java where "packages" are not that much more than
> directories. Each class can be exposed or hidden inside a package etc.
> In Java it is common that an API consists of many packages and
> subpackages. All classes are simply wrapped up in a JAR (Zip) file, and
> then they can be used as a library.
> What is common in D?
> Does a library have all its classes inside the same package (same
> directory) ? Or can you have multiple packages / subpackages inside the
> same library *and* same source root?
Organizing the code in D is quite similar as in Java. Although there's
no enforcement of a one to one mapping of classes and files. In D you
can have multiple public symbols in a module (file). Classes, structs,
functions, variables and so on.
Instead of using the reverse domain name as in Java, the convention is
to name the root package the same as the library/project name.
The distribution is done using Dub (see my other post).
More information about the Digitalmars-d-learn