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;
}



Reply via email to