Extending D's support for object-oriented design with private(this)

NotYouAgain NotYouAgain at gmail.com
Tue Apr 30 06:08:52 UTC 2024


On Tuesday, 30 April 2024 at 05:49:10 UTC, NotYouAgain wrote:
> On Tuesday, 30 April 2024 at 02:00:19 UTC, Lance Bachmeier 
> wrote:
>> ... If you make the case that this does not lead to a demand 
>> for friends, which I see as a strong argument, then maybe 
>> it'll have a chance. I think it's a reasonable addition to the 
>> language,...
>
> But I'm arguing against friends, not for friends.
>
> Friends already exist - ie, all code in the module is C++ 
> friend to your class, like it or not.
>
> For people that don't like the idea that C++ like friendship 
> might come to D, well. it's already here.. on steriods.
>
> Again, my single, only motivation, is to be able to declare a 
> private member in my class in the module.
>
> Why that is soooo.... contentious, is utterly bewildering.
>
> The D designer completely changed the “right” and “obvious” 
> meaning for private.
>
> Did he really expect there would be no pushback on that?

and the reason C++ friend always attaches itself to this topic, 
is because people insisted that the proposal was to change 
'private' to actually mean private, in which case some form of 
friendship would have needed to be added.

But private(this) does not replace private. private remains what 
is currently is. nobodys code will work any differently. people 
can choose to not use private(this), that is their choice.

But currently, absolutely nobody has the choice to declare a 
private member of a class 'within' a module. There a consequences 
for this. Convention does not scale. It did not scale in 
Javascript. It did not scale in Swift. They fixed their mistake.

D will not scale either, as it has the same mistake that they 
fixed.

As D is not used much, and where it is used, it's mostly C like 
programming anyway, there's not a lot of support for this idea, 
still. That's not too surprising really. But I guarantee, if D 
attractted lots of oo programmers, it would be faced with this 
issue constantly, and it would either have to fix it, or tell 
those programmers to go elsewhere - or tell them to put 
everything on its own in a module on its own to create that 
illusion. I wonder how well that idea will scale!

Being able to declare a private member of a class scope, in oop, 
is not a contentious idea! The idea for giving the programmer the 
'option' to do that within a module, does not warrant the kind of 
pushback it this idea gets.

There are plenty of completely useless features being added to D 
all the time. I never use any of them. I just want to declare a 
private member of my class. That is all.





More information about the dip.ideas mailing list