Package Declaration

Jonathan M Davis jmdavisProg at gmx.com
Wed Jun 6 02:45:37 PDT 2012


On Wednesday, June 06, 2012 10:33:58 Regan Heath wrote:
> I think it would be nice, and allow for most common designs to allow
> package access from sub-packages to parent packages, but not the other way
> round.  So, sub-package "Namespace.Graphics.Foo" could access package
> methods defined in parent package Namespace.Graphics modules, but
> Namespace.Graphics could not access Namespace.Graphics.Foo,
> Namespace.Graphics.Bar, etc.
> 
> What do you reckon?

I would think that in some cases you would want parent packages to have access 
to sub-packages' package stuff, and in some cases, you would want the reverse - 
or even both. But if you allow both, then that's the same as public, and even 
allowing it only one way is getting too close to public IMHO. And since people 
would sometimes want it one way and sometimes another, it would be a bit like 
the mess that typedef is - it frequently doesn't do quite what you want (hence 
why it's being removed from the language).

On the whole, it's just simpler for it to stay as it is, particularly since 
the language itself doesn't really have a concept of sub-packages. For 
instance, std is no different from std.etc.c or std.net as far as std.etc is 
concerned.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list