"Error: Undefined identifier" when moving import to another module
nrgyzer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 20 10:48:29 PDT 2014
On Monday, 20 October 2014 at 17:37:34 UTC, nrgyzer wrote:
> This solved the problem for the first time, BUT - I don't know
> if it's a bug or a feature - I ran into another problem. I'm
> having the following few lines:
>
> module example;
>
> private
> {
> string[string] myPrivateArray;
> }
>
> static this()
> {
> foreach ( m; __traits(allMembers, example) )
> {
>
> writefln("%s ::> %s", m, __traits(getProtection, m));
> }
> }
>
> void main() { /* empty */ }
>
> Compiling and running the application say's that myPrivateArray
> is public:
>
> myPrivateArray ::> public
>
> I declared myPrivateArray using the private keyword, but the
> dmd-trait `getProtection` says public. Why?
Ah, okay, I also need to use mixin(m) to get the protection. But
in this case, getProtection only works if I want retrieve the
protection for a variable, contained in the same module. I simply
can't use getProtection if I'm using the allMembers-trait for
another module where the variable is private...
More information about the Digitalmars-d-learn
mailing list