On Thu, 29 Mar 2012 20:27:46 -0400, Walter Bright
<[email protected]> wrote:
On 3/29/2012 5:09 PM, Steven Schveighoffer wrote:
The reason being, if you change anything in class A, you do not have to
worry
about the implementation of getXSquared, because it simply has no
access to the
private implementation. You only have to worry about internal methods,
and
friend functions.
Ok, I see what you're talking about. It has nothing to do with UFCS, it
is D's design decision to not have explicit friends, but to make
everything in a module implicitly a friend.
I think it's far superior to the explicit friend thing in C++.
I've never seen much cause for hiding things within the same module.
It's not like you're allowed to edit one part of the file and not touch
another part.
That is precisely what Scott Meyers recommends in the article you
referenced :) He *relies* on the fact that you can edit one part and not
worry about examining other parts (using his philosophy, it reduces the
amount of code you have to look at when changing private implementation).
FWIW, I agree with you, I think the C++ friend mechanism is awkward for
what it does, and I also don't take such hard-line views for code I write
(i.e. I don't mind putting code that doesn't access private members as a
member function).
-Steve