OT: Short review of an unself "paper" Re: D Language Foundation Weekly Planning Session Update

Theo Theo at gmail.com
Sun May 21 05:29:27 UTC 2023


On Saturday, 20 May 2023 at 23:24:12 UTC, surlymoor wrote:
> On Saturday, 20 May 2023 at 23:21:48 UTC, Theo wrote:
>> someone: "I want an option to have a class member to be 
>> private with a module."
>>
>> 10's of others: "That's an utterly ridiculous, perverted idea 
>> for the D language. Stop trolling us. OOP is bulls%%#. Nothing 
>> needs to be private. Just use structs and make everything 
>> public! We don't do that OOP crap in D anymore! If you keep 
>> saying this, we're going to block you, and we're going to 
>> filter you out in our Thunderbird settings.."
>>
>> and around and around it goes.... even still it seems (you 
>> being one of the main contributors to this merry-go-round!).
>
> Hello, forkit. I see you have yet to compose a DIP.

Well, now that you've brought the topic up....

The DIP would basically be as simple as this.

// ---

module someClass;

class C
{
    private(this) int x;
    void increment() {++x;}
}

unittest
{
     auto c = new C;
     c.x++; // please compiler, don't allow this - this was an 
typing accident.
     c.increment(); // yes, this was my intention. Thanks to 
private(this), the compiler now knows this too (not to mention 
people who look at the code).
}

// ----

The only objection I've encountered to this idea, seems to be 
wholly based on the idealogy of the sanctity of marriage .. I 
mean... the module.

Modularity and encapsulation can (and should be allowed to) apply 
at many levels of ones code (enums, functions, classes, module, 
packages....).

At the moment, there is no way to declare this intent in D. You 
have to put the unittest in a separate file as well - but even 
then, that does show intent, it's merely a workaround because you 
cannot delcare that intent .. in D.



More information about the Digitalmars-d mailing list