private module stuff

Jonathan M Davis jmdavisProg at gmx.com
Sun May 8 02:05:43 PDT 2011


> Sean Cavanaugh:
> > 	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?
> 
> You are expecting the right thing. If you are right, then it's a bug that
> eventually needs to be fixed. Take a look in Bugzilla, there are several
> already reported import/module-related bugs.

They're private _access_ but still visible. I believe that that is the correct 
behavior and not a bug at all. I believe that it's necessary for stuff like 
where various functions in std.algorithm return auto and return a private 
struct which you cannot construct yourself. Code which uses that struct needs 
to know about it so that it can use it properly, but since it's private, it 
can't declare it directly. It works because the types are appropriately 
generic (ranges in this case). Regardless, I believe that the current behavior 
with private is intended.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list