On Saturday, 17 March 2018 at 23:54:22 UTC, psychoticRabbit wrote:
On Saturday, 17 March 2018 at 21:33:01 UTC, Adam D. Ruppe wrote:
On Saturday, 17 March 2018 at 21:22:44 UTC, arturg wrote:
maybe extend that to a list of types?

this is basically what C++ friend does and D was trying to avoid the complexity of

Really, the complexity of 'friend' comes from people abusing it.

In D, I would prefer no breaking change here. Leave private as it is.

Just a simple attribute that only applies within a class, and only to private members within that class.

@strictly private string firstName_;

Nothing outside of the class, not even the module, can access this now. It's all encapsulated.

It breaks nothing (AFAIK).
It's very clear what the intention is here.
It's an easy attribute to remember.
It restores the principle of class enscapsulation within a module, for when it's really needed.

Now D programmers would have the best of both worlds.

Yesterday i thought to reuse `super`:

struct Foo
{
super private:
    int _stats;
    int _field;
public:
    int field(){_stats++; return _field;}
    void field(int value){_stats++; _field = value;}
}

BTW i think adding this can be useful. The FreePascal language has `strict private` for example.

Reply via email to