Required Reading: "How Non-Member Functions Improve Encapsulation"
Steven Schveighoffer
schveiguy at yahoo.com
Mon Oct 30 18:18:56 UTC 2017
On 10/30/17 1:40 PM, H. S. Teoh wrote:
> Page 2 of this article is essentially another reason why UFCS in D
> totally rawkz. In D, we can take Scott's advice *without* suffering
> from syntactic inconsistency between member and non-member functions:
You're missing a key piece here, in that anotherMethod does not ensure
the encapsulation of C. It can call 'method' just fine.
Yes, it's great that UFCS can help with encapsulation via external
methods, but it's going to be difficult to prevent access to private
data, you have to use 2 modules. Not a very clean solution IMO.
-Steve
More information about the Digitalmars-d
mailing list