encapsulation

BCS ao at pathlink.com
Tue Mar 13 15:24:17 PDT 2007


Reply to torhu,

> BCS wrote:
> 
>> If I understand correctly, the idea is to get rid of friend but still
>> let some things look inside of others. This solution lets closed set
>> of code interact at a low level while doing encapsulation at wider
>> scopes. The reason friend is discarded is that it has the power to do
>> arbitrary snooping which causes the same kind of problems as goto's
>> arbitrary redirection causes.
>> 
> 'friend' doesn't work they way you're implying here.
> 
> 

Yes, friend acts as an invitation, however there are no limitations on who 
a class can invite. This is "arbitrary snooping" I was talking about. With 
D's private semantics, that same "you can look at my private stuff" ability 
is limited to a finite set of code. It is somewhat like how goto can go to 
most anywhere in a function but labeled break and continues can only go to 
the start or end of a loop.





More information about the Digitalmars-d mailing list