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

NotYouAgain NotYouAgain at gmail.com
Sat Apr 27 07:12:16 UTC 2024


On Saturday, 27 April 2024 at 06:48:47 UTC, Jonathan M Davis 
wrote:
> ..
> ...
> ... So, from my perspective, you're trying to solve a problem 
> that isn't even a problem in the first place.

Mmm. This is where you don't understand my motivation.

I'm not saying that it's causing widespread problems and that it 
needs to be addressed.

I'm saying, I want to prevent the problem from even occuring.

Almost any newcomer to D, will experience this problem.

There is no solution to them, other than to 'be more careful', or 
put the class in a module by itself, and ensure any unittest 
testing it, is also in another separate module. In that is 
solution being proposed to 'prevent' the problem'.

My proposal is more likely be used, as it's so much easier.

You present the hard solution to preventing the problems, I 
present the easy solution.

If I understand correctly, that seems to be where we differ.

You saying -> be careful not to do it so that it doesn't cause 
problems, or put use separate modules for everything.

Me saying -> use private(this)

A class is 'a type' of a particular thing, describing its 
properties and how it is to be interacted with, just like 
anyother type. If people come to D with that mindset, they will 
make mistakes, just like most newcomers make that mistake. 
Forcing them to think of the class as a subtype of the module, is 
not going to work. They'll just go elsewhere (which may well me 
the desriable outcome for some ;-)



More information about the dip.ideas mailing list