Very hacky solution to class private members

Dom Disc dominikus at scherkl.de
Thu Jun 9 10:39:17 UTC 2022


On Thursday, 9 June 2022 at 10:26:31 UTC, Ola Fosheim Grøstad 
wrote:
> On Thursday, 9 June 2022 at 10:03:02 UTC, Dom Disc wrote:
>> But what about all the member-functions of a class, that also 
>> should not have access to some variables? (Because most of the 
>> time, private members should only be accessed by a few members 
>> that are designed to work with them). There neither private or 
>> hidden on whatever level can help you.
>
> I personally use underscore for member functions or class 
> fields that has to be handled with care.

Whatever you do, it needs to be something human-readable, because 
the compiler can't help you there.

> But if you look at the D standard library you see that some 
> modules are convoluted and in such settings it would be better 
> with another protection level.

No.
If something is convoluted, you need to sort it out and split 
into two modules. Another protection level won't help. Because, 
as I said, a new level won't reduce your effort to understand 
whats happening, you still need to inspect everything within the 
file. But splitting would help a lot with that.

> In general if somebody wants to improve the language then they 
> can find many of the problem spots in the D standard library 
> and use that for making judgments.

Jup. But new privacy-levels are no solution to them.

> If someone ever started on D3, that is the place to start IMO.

Sorting things out should be possible without need for an new 
fork. It should be done withing the actual phobos as it wouldn't 
change the interface (at least not much).


More information about the Digitalmars-d mailing list