Scope of D packages

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 18 16:09:16 PST 2015


On Friday, 18 December 2015 at 23:20:34 UTC, 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?

each sub directory in a package is also a package

lib/package.d : allow to put all the lib modules as public import
lib/module1.d : this is module 1 from package lib
lib/module2.d : this is module 2 from package lib
lib/sub1/package.d : allow to put all the lib.sub1 modules as 
public import
lib/sub1/module1: this is module 1 from package lib.sub1
lib/sub1/module2: this is module 2 from package lib.sub1

but when you compile 'lib' library it's a monolithic *.a or *.lib 
file, which still requires the sources.

look at https://github.com/gecko0307/dlib/tree/master/dlib 
structure for example.


More information about the Digitalmars-d-learn mailing list