Comment #0 by jarrett.billingsley — 2006-05-17T17:28:03Z
It doesn't work. I've tried so many things. It never prevents any kind of access.
Assume the following directory structure:
/proj/test.d
/proj/modules/foo.d
And the files:
[test.d]
module test;
import modules.foo;
void main()
{
writefln(x);
}
[foo.d]
module modules.foo;
package int x = 5;
This happily compiles and runs, printing 5.
I've tried multiple levels of directories/packages, different kinds of declarations, moving the import file somewhere else.. nothing.
Comment #1 by thomas-dloop — 2006-05-19T11:45:37Z
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email protected] schrieb am 2006-05-17:
> It doesn't work. I've tried so many things. It never prevents any kind of
> access.
The implementations of "private", "package" and "protected" are broken.
Details can be found in the digitalmars.D.bugs group by searching for
"private" or "package".
Test cases:
http://dstress.kuehne.cn/www/dstress.html#private_07
Thomas
-----BEGIN PGP SIGNATURE-----
iD8DBQFEbc3k3w+/yD4P9tIRAq13AJ9+GSHvj8Kw4YpkSzBlPPYqXfO/TACfaYYf
RLemX8Un1IofG+uW9OQ8ryQ=
=jABO
-----END PGP SIGNATURE-----
Comment #2 by michal.minich — 2010-12-09T04:45:31Z
test for package and private in DMD 2.050 shows that only functions and functions aliases works for both modifiers; and variables works for private only.
[test.d]
import pack.mod;
void main () {
i = 1;
//pi = 1; // OK - Error: module main pack.mod.pi is private
S s;
C c = new C;
U u;
//fn (); // OK - Error: function mod.fn is not accessible from main
//aFn (); // OK - Error: function mod.fn is not accessible from main
aS as;
}
[pack/mod.d]
module pack.mod;
package : // private is ignored too
int i;
struct S {}
class C {}
union U {}
alias S aS;
// these works OK
void fn () {}
alias fn aFn;
private int pi;
Comment #3 by github-bugzilla — 2012-02-18T11:04:47Z