private module stuff

Sean Cavanaugh WorksOnMyMachine at gmail.com
Sun May 8 01:07:20 PDT 2011


	So I was learning how to make a module of mine very strict with private 
parts, and was surprised I could only do this with global variables and 
functions.   Enums, structs, and classes are fully visible outside the 
module regardless of being wrapped in a private{} or prefixed with 
private.  Am I expecting too much here?



rough code:


module mymoduletree.mymodule;

private
{
struct foo
{
int x;
int y;
}

int somevar = 4;
}


.....


module someothertree.othermodule;

import mymoduletree.mymodule;

int bar(int arg)
{
     foo var;  // why can i use this type here??
     var.x = arg;
     var.y = somevar;  // this generates an error (access of somevar is 
private and not allowed)
     return var.y;
}





More information about the Digitalmars-d-learn mailing list