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

NotYouAgain NotYouAgain at gmail.com
Sun Apr 28 23:59:52 UTC 2024


On Sunday, 28 April 2024 at 20:49:37 UTC, Dukc wrote:
> ..
> ...

and look at the lengths one has to go to, to explain, and 
understand, what private in D means:

https://dlang.org/blog/2018/11/06/lost-in-translation-encapsulation/

But if D has private(this), that article could have just been a 
one liner:

"If you need private to the class, use private(this)".

Done. Decades of confusion, useless converstations about it, all 
done away with.

You won't need that article for OpenD ;-)  .. just tell people to 
use private(this).

Now if anyone has the programming skills to submit a PR to OpenD 
for protected(this), please feel free to do so ;-)

And yes, this is 'campaign' - a campaign to be able to think 
about objects as being a unit of encapsulation (in addition to 
the module being a unit of encapsulation).

Then programmers can finally take control over D's mistake (to 
take that control away from them), and they can decide what is 
best for them .. just like they can do in Swift.



More information about the dip.ideas mailing list