On 3/29/2012 6:57 PM, Nick Sabalausky wrote:
How the heck does that improve encapsualtion? With D's implicit friends, it *doesn't*, it's just shifting things around. There is NO encapsualtion benefit there. Like Steven said, to *get* the encapsualtion, you have to create a whole new module to stick "extraFunctionality" into.
It doesn't improve intra-module encapsulation, you're right. The point of UFCS, however, is so that *other* modules can extend a class's methods without breaking encapsulation.
In D, the module is the fundamental unit of encapsulation, not the class. The reason is the whole reason that friends exist - sometimes, more than one component (i.e. class) is needed to manipulate private state.
