Package explain

Fawzi Mohamed fmohamed at mac.com
Thu Aug 21 09:10:46 PDT 2008


On 2008-08-21 16:51:26 +0200, "Jarrett Billingsley" <kb3ctd2 at yahoo.com> said:

> "Zarathustra" <adam.chrapkowski at gmail.com> wrote in message
> news:g8jdfc$cqk$1 at digitalmars.com...
>> Could anybody explain what "package" exctly mean?
>> 
>> module package1.module1;
>> static int variable = 3;
> 
> "static" does not make variables private as in C.  "private" does that.
> Declarations are implicitly public, hence why you can access it in main.

yes  static int variable = 3; actually means
public static int variable =3;
if you write
private static int variable =3;
you can't access it from any other module
if you write
package static int variable =3;
you can access it from module2 and module3 (that are in the same 
package) but not from main.

> 
>> module package1.module2;
>> 
>> module package1.module3;
>> package import package1.module1, package1.module2;
> 
> Yeah, what the hell is "package import"?

this is most likely not implemented, it is documented nowhere, you 
might expect it for symmetry reasons, but it is not there.
If you think it should be there (and really I cannot think a good case 
in which you need it) try filing a bug report...

Fawzi
> 
>> module main;
>> import package1.module3;
>> 
>> void main(){
>> variable1 = 5;  // Why variable is accessable?
>> }
>> 
>> |
>> |--- main
>> |--- package1
>> |
>> |--- module1
>> |--- module2
>> |--- module3
>> 
>> I'm dsss user.




More information about the Digitalmars-d-learn mailing list