digitalmars.D.bugs - enums not made private
- Nick (16/16) Feb 09 2005 test_module.d:
- Jarrett Billingsley (4/4) Feb 09 2005 I posted this two weeks or so ago and never got any response. In the
- Regan Heath (24/39) Feb 09 2005 In the above you are:
- Nick (8/13) Feb 10 2005 Ok, that is somewhat confusing and a bit limiting. What do you do if you...
- Regan Heath (8/25) Feb 10 2005 It doesn't seem to be a big problem, though I can understand the desire ...
- Nick (4/10) Feb 11 2005 Yes, thats what I'm saying.
- Carlos Santander B. (4/25) Feb 10 2005 _______________________
- =?ISO-8859-1?Q?Thomas_K=FChne?= (35/35) Feb 11 2005 -----BEGIN PGP SIGNED MESSAGE-----
- Jarrett Billingsley (1/4) Feb 20 2005 And if this is how it's supposed to work, then.. sigh, Walter. ;)
I posted this two weeks or so ago and never got any response. In the interest of making the world a better place (and D a better language), I'll agree with you that enums (as well as classes, structs, and unions) should actually be private if they are declared as such.
Feb 09 2005
On Wed, 9 Feb 2005 22:46:16 +0000 (UTC), Nick <Nick_member pathlink.com> wrote:test_module.d:In the above you are: 1- creating an instance of an int called A and assigning a value 1 to it. 2- declaring an unnamed enum which has 1 member B with a value 2. I think that currently D does not apply 'private' to declarations, only instances, eg. the enum above is similar to: Which declares a class called A which is not treated as 'private' either. That said, if you say: D does stop you from instantiating the class. The questions are: 1- is the above this a declaration or an instance or both? 2- should private apply to a declaration? or only an instance?program.d:Regan
Feb 09 2005
In article <opslynqtqc23k2f5 ally>, Regan Heath says...In the above you are: 1- creating an instance of an int called A and assigning a value 1 to it. 2- declaring an unnamed enum which has 1 member B with a value 2. I think that currently D does not apply 'private' to declarations, only instancesOk, that is somewhat confusing and a bit limiting. What do you do if you don't want a declaration to be available outside the module? It looks like the only option is to put it in yet another module, and do a private import: module A: enum { TEST = 1; } module B: private import A; program: import B; // TEST is unavailable Nick
Feb 10 2005
On Thu, 10 Feb 2005 14:36:45 +0000 (UTC), Nick <Nick_member pathlink.com> wrote:In article <opslynqtqc23k2f5 ally>, Regan Heath says...It doesn't seem to be a big problem, though I can understand the desire to not pollute the namespace with un-necessary symbols.In the above you are: 1- creating an instance of an int called A and assigning a value 1 to it. 2- declaring an unnamed enum which has 1 member B with a value 2. I think that currently D does not apply 'private' to declarations, only instancesOk, that is somewhat confusing and a bit limiting. What do you do if you don't want a declaration to be available outside the module?It looks like the only option is to put it in yet another module, and do a private import: module A: enum { TEST = 1; } module B: private import A; program: import B; // TEST is unavailableIt doesn't stop them importing B themselves and using your declaration. I guess we're saying private should apply to a declaration in the same way it applies to an instance, right? Regan
Feb 10 2005
In article <opslz02hd623k2f5 ally>, Regan Heath says...Nope. But the point was, as you said, to not polute the namespace.module A: enum { TEST = 1; } module B: private import A; program: import B; // TEST is unavailableIt doesn't stop them importing B themselves and using your declaration.I guess we're saying private should apply to a declaration in the same way it applies to an instance, right?Yes, thats what I'm saying. Nick
Feb 11 2005
Nick wrote:In article <opslynqtqc23k2f5 ally>, Regan Heath says...I'd instead call it a bug.In the above you are: 1- creating an instance of an int called A and assigning a value 1 to it. 2- declaring an unnamed enum which has 1 member B with a value 2. I think that currently D does not apply 'private' to declarations, only instancesOk, that is somewhat confusing and a bit limiting. What do you do if you don'twant a declaration to be available outside the module? It looks like the only option is to put it in yet another module, and do a private import: module A: enum { TEST = 1; } module B: private import A; program: import B; // TEST is unavailable Nick_______________________ Carlos Santander Bernal
Feb 10 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Carlos Santander B. wrote: | Nick wrote: | |> In article <opslynqtqc23k2f5 ally>, Regan Heath says... |> |>> In the above you are: 1- creating an instance of an int called A |>> and assigning a value 1 to it. 2- declaring an unnamed enum which |>> has 1 member B with a value 2. |>> |>> I think that currently D does not apply 'private' to |>> declarations, only instances |> |> |> |> Ok, that is somewhat confusing and a bit limiting. What do you do |> if you don't | | I'd instead call it a bug. | http://digitalmars.com/d/attribute.html 1) instead of "class" it should read "module or class scope" 2) Are type declarations members? I didn't find anything about that. If type declarations are members, this is a bug. If they aren't member this is in my view a flaw in the specification. Thomas -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (MingW32) iD8DBQFCDUcv3w+/yD4P9tIRAnufAJ9GkPYsu0gBZmV4wSm56A8gHKPERwCdHxsT 2c+Lwjg39FsOnAbR8AizCk0= =7UoJ -----END PGP SIGNATURE-----
Feb 11 2005
2) Are type declarations members? I didn't find anything about that. If type declarations are members, this is a bug. If they aren't member this is in my view a flaw in the specification.And if this is how it's supposed to work, then.. sigh, Walter. ;)
Feb 20 2005