Module level privacy

Jonathan M Davis jmdavisProg at gmx.com
Mon Jun 11 11:12:49 PDT 2012


On Monday, June 11, 2012 19:59:24 Jarl André" 
<jarl.andre at gmail.com>@puremagic.com wrote:
> Hi
> 
> I just noticed that by setting a class to private in a module,
> its not inaccessible by other modules including the mentioned
> module. What am I saying syntactically when I am setting a class
> to private in a module? Will it be hidden by third level
> includers? (a module C that includes module B that includes
> module A that contains private class Z)? Or is the private
> modifier practically useless at module level?

Classes aren't affected by public, private, etc. Their members are. So, if you 
mark a class as private, that just makes all of its members private. That 
doesn't prevent you from declaring a variable of that type. It just prevents 
you from constructing it or using any of its members. Also, if you're dealing 
with a template, then private is currently ignored, which is definitely a bug ( 
http://d.puremagic.com/issues/show_bug.cgi?id=2775 ).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list