digitalmars.D - Need more fine-grained access control
- Matthew (14/14) Apr 30 2005 Is there a mechanism for making things private to the current class
- Thomas Kuehne (11/19) May 01 2005 -----BEGIN PGP SIGNED MESSAGE-----
- Matthew (3/17) May 01 2005 I can't say, as I don't know what that means. Can you elucidate?
- Thomas Kuehne (13/30) May 01 2005 -----BEGIN PGP SIGNED MESSAGE-----
- Matthew (4/33) May 01 2005 I'm think I'm getting hints at what you mean, but need more info.
- Derek Parnell (15/54) May 01 2005 All identifiers in a single file are visible to any code also in the sam...
- Thomas Kuehne (49/84) May 01 2005 -----BEGIN PGP SIGNED MESSAGE-----
- Ben Hinkle (6/20) May 01 2005 ^^^^^^^
- Matthew (6/30) May 01 2005 For package? Maybe I do. I could be massively ignorant on this
- Ben Hinkle (9/40) May 02 2005 a module is a file. a package is a directory. C++/Java/C# have no real
- Sean Kelly (7/15) May 02 2005 You could use "protected." Though this obviously means that the data is...
Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid. How about a "private private" qualifier. (Of course, I don't think anything should be able to see inside anything else by default, but that's not going to change, so this is the next best thing.) Thoughts?
Apr 30 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Matthew schrieb am Sun, 1 May 2005 16:36:05 +1000:Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.What is the problem with using 2+ modules in the same package? <snip> Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCdIq43w+/yD4P9tIRAiUvAKCt12H2xyyMbyPBIzYI05XGIyaI9wCdG54V MZMvAChaQOntufIuZrRFkM4= =l+P0 -----END PGP SIGNATURE-----
May 01 2005
"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message news:peeek2-la7.ln1 lnews.kuehne.cn...-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Matthew schrieb am Sun, 1 May 2005 16:36:05 +1000:I can't say, as I don't know what that means. Can you elucidate?Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.What is the problem with using 2+ modules in the same package?
May 01 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Matthew schrieb am Sun, 1 May 2005 18:00:06 +1000:"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message news:peeek2-la7.ln1 lnews.kuehne.cn...Modules b and c are part of the same package a: module a.b; module a.c; Now you can use the access attribute "package" for more fine-grained control. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCdJAo3w+/yD4P9tIRAkXjAKDO34wtw/3KQ9wysopQCQsYCf3Z6gCfRWJ4 08jmz4fs97zYSoLuU0vbSv8= =iKCB -----END PGP SIGNATURE-----Matthew schrieb am Sun, 1 May 2005 16:36:05 +1000:I can't say, as I don't know what that means. Can you elucidate?Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.What is the problem with using 2+ modules in the same package?
May 01 2005
"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message news:8qfek2-la7.ln1 lnews.kuehne.cn...-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Matthew schrieb am Sun, 1 May 2005 18:00:06 +1000:I'm think I'm getting hints at what you mean, but need more info. Can you show with a bit more code?"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message news:peeek2-la7.ln1 lnews.kuehne.cn...Modules b and c are part of the same package a: module a.b; module a.c; Now you can use the access attribute "package" for more fine-grained control.Matthew schrieb am Sun, 1 May 2005 16:36:05 +1000:I can't say, as I don't know what that means. Can you elucidate?Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.What is the problem with using 2+ modules in the same package?
May 01 2005
On Mon, 2 May 2005 14:18:00 +1000, Matthew wrote:"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message news:8qfek2-la7.ln1 lnews.kuehne.cn...All identifiers in a single file are visible to any code also in the same file. This is regardless of any 'private' or 'package' attribute. All 'private' identifiers in a file are hidden to code that is in any other files. All 'package' identifiers in a file are hidden to code that is in any other file that is also in another directory. They are not hidden to code in files that are in the same directory. All other identifies are visible to code in any file in any directory. -- Derek Parnell Melbourne, Australia http://www.dsource.org/projects/build/ v2.05 released 02/May/2005 http://www.prowiki.org/wiki4d/wiki.cgi?FrontPage 2/05/2005 3:03:10 PM-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Matthew schrieb am Sun, 1 May 2005 18:00:06 +1000:I'm think I'm getting hints at what you mean, but need more info. Can you show with a bit more code?"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message news:peeek2-la7.ln1 lnews.kuehne.cn...Modules b and c are part of the same package a: module a.b; module a.c; Now you can use the access attribute "package" for more fine-grained control.Matthew schrieb am Sun, 1 May 2005 16:36:05 +1000:I can't say, as I don't know what that means. Can you elucidate?Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.What is the problem with using 2+ modules in the same package?
May 01 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Matthew schrieb am Mon, 2 May 2005 14:18:00 +1000:"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message news:8qfek2-la7.ln1 lnews.kuehne.cn...Congratulations, seems you have unearthed a bug with "package" and "protected". I'm not yet sure when/why but sometimes the access restrictions are ignored. - --------- module a.b; class Foo{ private int a; package int b; protected int c; public int d; } - --------- module a.c; import a.b; void bar(Foo f){ f.a=0; // illegal f.b=1; // OK f.c=2; // OK f.d=3; // OK } - --------- module some.third.party; import a.b; class Bar : Foo{ void check(Foo f){ a=0; // illegal b=1; // illegal /* BUG */ c=2; // OK d=3; // OK } } - --------- module another.third.party; import a.b; void check(Foo f){ f.a=0; // illegal f.b=1; // illegal /* BUG */ f.c=2; // illegal /* BUG */ f.d=3; // legal } Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCdbV/3w+/yD4P9tIRAsl8AKCgQA99zJlbUPT3jQs/ctrlJnPPggCdF+D4 GFNg7CWEnMn/QANcOqdk3AQ= =mj5T -----END PGP SIGNATURE-----Matthew schrieb am Sun, 1 May 2005 18:00:06 +1000:I'm think I'm getting hints at what you mean, but need more info. Can you show with a bit more code?"Thomas Kuehne" <thomas-dloop kuehne.thisisspam.cn> wrote in message news:peeek2-la7.ln1 lnews.kuehne.cn...Modules b and c are part of the same package a: module a.b; module a.c; Now you can use the access attribute "package" for more fine-grained control.Matthew schrieb am Sun, 1 May 2005 16:36:05 +1000:I can't say, as I don't know what that means. Can you elucidate?Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.What is the problem with using 2+ modules in the same package?
May 01 2005
"Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message news:d51vdc$23uo$1 digitaldaemon.com...Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.^^^^^^^ I assume you mean "module"?How about a "private private" qualifier. (Of course, I don't think anything should be able to see inside anything else by default, but that's not going to change, so this is the next best thing.) Thoughts?Everything in the same module are "friends" to each other. If one has two classes that aren't friends put them in different modules.
May 01 2005
"Ben Hinkle" <ben.hinkle gmail.com> wrote in message news:d52rrf$2ovp$1 digitaldaemon.com..."Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message news:d51vdc$23uo$1 digitaldaemon.com...For package? Maybe I do. I could be massively ignorant on this issue.Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.^^^^^^^ I assume you mean "module"?But are they not then in different 'namespaces'? How do I refer to them in some third-party code?How about a "private private" qualifier. (Of course, I don't think anything should be able to see inside anything else by default, but that's not going to change, so this is the next best thing.) Thoughts?Everything in the same module are "friends" to each other. If one has two classes that aren't friends put them in different modules.
May 01 2005
"Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message news:d54a26$qks$2 digitaldaemon.com..."Ben Hinkle" <ben.hinkle gmail.com> wrote in message news:d52rrf$2ovp$1 digitaldaemon.com...equivalent of file-protection."Matthew" <admin stlsoft.dot.dot.dot.dot.org> wrote in message news:d51vdc$23uo$1 digitaldaemon.com...For package? Maybe I do. I could be massively ignorant on this issue.Is there a mechanism for making things private to the current class only, and _not_ the package. For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.^^^^^^^ I assume you mean "module"?That's true - they would be in different namespaces. One can alias together but that would be annoying to do for small internal data structures. On the other hand small internal data structures have a low risk of being misused by the code in the same file. Personally I'd just keep them in one module. One can protect oneself from oneself only so much (IMO).But are they not then in different 'namespaces'? How do I refer to them in some third-party code?How about a "private private" qualifier. (Of course, I don't think anything should be able to see inside anything else by default, but that's not going to change, so this is the next best thing.) Thoughts?Everything in the same module are "friends" to each other. If one has two classes that aren't friends put them in different modules.
May 02 2005
In article <d51vdc$23uo$1 digitaldaemon.com>, Matthew says...Is there a mechanism for making things private to the current class only, and _not_ the package.You could use "protected." Though this obviously means that the data is visible to a derived class.For example, in the expansion to Open-RJ we need to be able to prevent the Record class from having write access to any of the members of the Field class, in order to ensure there are no erroneous breaking of the immutable characteristics of the Field type. But because they are - have to be - defined in the same package, anything can scribble on anything else. Horrid.I'd like to believe that a module writer won't violate principles he's invented. But I agree that it would be nice to have an easy way to verify this at compilation-time. Sean
May 02 2005