On Tue, 05 Jun 2012 10:29:23 +0100, Jonathan M Davis <jmdavisp...@gmx.com>
wrote:
On Tuesday, June 05, 2012 11:08:03 Namespace wrote:
Currently i have all of my Files in the same Directory.
Now i will split them up in several specific Sub-Directories,
e.g. Graphics, System and so one. But i have a problem: Some
Files of one Sub-Directory call methods from Files which are in
other Sub-Directories.
Up to now i have no problem, because if all of them are in the
same Directory i can define the method under the "package" label
and any other Module in the same Package can access the method.
What if I have Subpackages? E.G. Namespace.Graphics.Foo will
access a method in Namespace.System.Bar. "package" doesn't work
anymore, although they are in the same main Package. Ist that a
Bug? And what should i do?
In C++ i can use the friend declaration and i thougth i D
"package" are the equivalent.
Sorry for my english.
package is only for modules in the same package, and a package is made
up of
all of the modules within a directory. Sub-directories are not part of
the
package. Sub-packages do not have access to package functions in their
parent
package, nor does a parent package have access to package functions in
its
sub-packages. Anything shared between them must be public. There is no
way to
give other packages (be they sub-packages or otherwise) access to a
package's
functions other than through public (or protected if you're dealing with
inheritance).
As for friend, D's solution was to make private be private to a module
rather
than a class or struct. So, everything within a module is effectively a
friend
to everything else in that module. package comes from Java.
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?
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/