'package' and access from subpackages..

Jarrett Billingsley kb3ctd2 at yahoo.com
Fri Aug 29 15:51:59 PDT 2008


"Sergey Gromov" <snake.scaly at gmail.com> wrote in message 
news:MPG.2322860868338f629896b1 at news.digitalmars.com...

> I can see two approaches to packages: plain and hierarchical.
>
> D, like Java, uses the plain approach: each package is on its own, and
> packages communicate via public and protected interfaces. This
> necessitates introducing additional, documentation-level contracts on
> which packages of a library are interface and which are implementation
> details.
>
> A pre-compiled library can enforce this by supplying .di files only for
> interface modules. It also can encourage the proper use by supplying a
> single import module.
>
> Another approach is to have hierarchical packages, which sounds close to
> the concept of nested classes and C++ namespaces. So that inner packages
> have access to anything with package access in all outer packages. But
> how do the outer packages communicate with inner? Inner packages are
> required to have interfaces which are public for some outer packages but
> private for some more outer packages. I cannot see an easy solution
> here.

I was thinking that you would put the more generic stuff towards the top of 
the package hierarchy and the more specialized stuff towards the bottom, so 
that the generic stuff wouldn't actually have to access the specialized 
stuff.  I.e. you would declare interfaces in package.*, but you would 
implement them in package.impl.*. 





More information about the Digitalmars-d mailing list