Module-level visibility

Lutger lutger.blijdestijn at gmail.com
Mon Feb 15 23:51:45 PST 2010


bearophile wrote:

> I have shown this little program to some of my friends that program in
> Java/C#:
> 
> class Foo {
>     private int x;
> }
> void main() {
>     Foo f = new Foo;
>     f.x = 5;
> }
> 
> 
> When I say them this code compiles with D2 they usually tell me that the
> compiler has a bug. So I suggest Walter to ask other people, maybe at
> Google or else (and in this newsgroup too), if they think this feature of
> D2 is a good thing, before this feature is set in stone in D2 (I have no
> definite answer about this topic, I can't help you). If you are really
> sure this is a good feature, then you can ignore this post.
> 
> Bye,
> bearophile

I think that's because in C#/Java data-hiding is conceived as an object 
oriented feature. It is not really surprising, since data hiding is the 
principal means of modularity and in C++/C#/Java that can (almost) only be 
achieved on the class level. 

It kinda makes sense for D to support data-hiding on the module level since 
object orientation is not the only or privileged programming style. 



More information about the Digitalmars-d mailing list