Preventing writes to a global struct instance with const?
Derek Parnell
derek at nomail.afraid.org
Wed Jan 31 16:23:18 PST 2007
On Wed, 31 Jan 2007 15:33:24 -0800, Bradley Smith wrote:
> Why doesn't private protection work on structs?
The 'private' protection means that such items cannot be accessed by things
in other *modules* and not just other classes/structs. In other words, any
thing in a module has access to everything in the same module.
However, a long-existing bug means that you can still subvert this
protection by simply referencing a private item in a different module by
using it's fully qualified name.
-------
module foo;
private int A;
-------
module bar;
import foo;
. . .
foo.A = 42; // Allowed but should not be.
A = 42; // Correctly disallowed.
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
1/02/2007 11:17:14 AM
More information about the Digitalmars-d-learn
mailing list