We need an internal keyword.

Nick Sabalausky (Abscissa) SeeWebsiteToContactMe at semitwist.com
Mon Oct 22 02:25:24 UTC 2018


On 10/20/18 11:17 PM, 12345swordy wrote:
> So that classes can share some of their variables but not others in a 
> module.
> 
> IE.
> 
> class A
> {
> internal int A; //This is shared in the module
> private int B; // But not this.
> }
> 
> No need to reintroduce the "Friend" feature from cpp.

I've always felt the same.

I certainly don't intend this as a way to say "just accept it and forget 
about it", but FWIW, I've learned to live with it: I just regard 
accessing such privates from outside their class/struct to be bad style. 
I mean, I agree it's not ideal, but at least it doesn't prevent me from 
getting things done. Again, FWIW.

That said though, it *can* sometimes be helpful for tests and debugging 
to be able to reach into a class/struct and muck about with the 
privates. (tee hee). But FWIW, I do agree. If D were my own language, 
I'd probably have done it a little differently: I would've taken the 
current "private" behavior and called it something like "module", and 
made "private" behave the way it does in other languages.



More information about the Digitalmars-d mailing list