Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
August 21, 2008 Package explain | ||||
---|---|---|---|---|
| ||||
Could anybody explain what "package" exctly mean? module package1.module1; static int variable = 3; module package1.module2; module package1.module3; package import package1.module1, package1.module2; module main; import package1.module3; void main(){ variable1 = 5; // Why variable is accessable? } | |--- main |--- package1 | |--- module1 |--- module2 |--- module3 I'm dsss user. |
August 21, 2008 Re: Package explain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zarathustra | On Thu, 21 Aug 2008 05:45:16 -0400, Zarathustra wrote:
> Could anybody explain what "package" exctly mean?
>
> module package1.module1;
> static int variable = 3;
>
> module package1.module2;
>
> module package1.module3;
> package import package1.module1, package1.module2;
>
> module main;
> import package1.module3;
>
> void main(){
> variable1 = 5; // Why variable is accessable?
> }
>
> |
> |--- main
> |--- package1
> |
> |--- module1
> |--- module2
> |--- module3
>
> I'm dsss user.
I don't see anything in the docs about a package import. Public, Private, Static, but not Package.
|
August 21, 2008 Re: Package explain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Zarathustra | "Zarathustra" <adam.chrapkowski@gmail.com> wrote in message news:g8jdfc$cqk$1@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. > module package1.module2; > > module package1.module3; > package import package1.module1, package1.module2; Yeah, what the hell is "package import"? > module main; > import package1.module3; > > void main(){ > variable1 = 5; // Why variable is accessable? > } > > | > |--- main > |--- package1 > | > |--- module1 > |--- module2 > |--- module3 > > I'm dsss user. |
August 21, 2008 Re: Package explain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | On 2008-08-21 16:51:26 +0200, "Jarrett Billingsley" <kb3ctd2@yahoo.com> said: > "Zarathustra" <adam.chrapkowski@gmail.com> wrote in message > news:g8jdfc$cqk$1@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. |
August 22, 2008 Re: Package explain | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jesse Phillips | Jesse Phillips a écrit :
> On Thu, 21 Aug 2008 05:45:16 -0400, Zarathustra wrote:
>
>> Could anybody explain what "package" exctly mean?
>>
>> module package1.module1;
>> static int variable = 3;
>>
>> module package1.module2;
>>
>> module package1.module3;
>> package import package1.module1, package1.module2;
>>
>> module main;
>> import package1.module3;
>>
>> void main(){
>> variable1 = 5; // Why variable is accessable?
>> }
>>
>> |
>> |--- main
>> |--- package1
>> |
>> |--- module1
>> |--- module2
>> |--- module3
>>
>> I'm dsss user.
>
> I don't see anything in the docs about a package import. Public, Private, Static, but not Package.
Here goes my opinion about this again: any modifier that doesn't make sense in a given context, should be a compiler error. This thread is and example of what happens if this is not the case.
|
Copyright © 1999-2021 by the D Language Foundation