Extending D's support for object-oriented design with private(this)
NotYouAgain
NotYouAgain at gmail.com
Thu Apr 25 09:25:38 UTC 2024
On Thursday, 25 April 2024 at 08:08:40 UTC, Dom DiSc wrote:
> On Thursday, 25 April 2024 at 06:05:23 UTC, zjh wrote:
>>
>> This improvement has no `side effects` on the `d` language. I
>> really don't know why they `oppose` it?
>
> Opposition was only because of "friend"s, which destroys
> encapsulation in an unpredictable manner. As long as no
> "friend" attribute is proposed, everything is fine. Already
> works without problems in OpenD.
If my understanding is correct, the concern was not about
'friends' but 'C++ like' friends.
That is, friends that could essentially be anywhere.....and
difficult to track down.
But D also has a 'friends' notion, implicately. That is, all code
in the module is essentially a friend of any class in the module,
and within a package of modules, that notion extends further.
It's implicit in D, because the module is the unit of
encapsulation, not the class.
So I'd say that D understands the necessity for a friend feature
- it just restricts the borders of its use (i.e. to the module,
or a package of modules).
This idea never involved the concept of 'C++ like' friends, nor
would it even be needed, since a more suitably 'constrained
border' for friendship is already in D - i.e. the module (or
modules within a package).
And yes, I'm not aware of any problems using this feature that is
already in OpenD ;-)
More information about the dip.ideas
mailing list