private keyword dont appear to do anything

Steven Schveighoffer schveiguy at yahoo.com
Fri Nov 3 21:43:55 UTC 2017


On 11/3/17 5:08 PM, Nathan S. wrote:
> On Friday, 3 November 2017 at 20:01:27 UTC, Jonathan M Davis wrote:
>> Most folks are surprised by this behavior
> 
> I found it surprising at first but now any other way seems absurd to me. 
> None of the benefits of data encapsulation apply to code written five 
> lines away in the same file.

I also enjoy the mechanism, but I have to call this out as incorrect. 
Encapsulation is about being able to prove to yourself exactly how an 
object's private data can possibly be manipulated. It's not just 5 lines 
away, it's the whole file you have to review.

If you have large flat files like Phobos, then encapsulation is 
essentially impossible to review.

-Steve


More information about the Digitalmars-d-learn mailing list