Adding a new design constraint to D
forkit
forkit at gmail.com
Sun Jun 26 06:01:05 UTC 2022
On Sunday, 26 June 2022 at 01:28:46 UTC, forkit wrote:
>
Here I introduce a new concept, which (for now), we'll call a
'view'.
It can solve multiple problems.
First, it eliminated a need for 'private(this)'
Second, it allows fine grained control of member access, to
member variables.
Anything declared private, in a view, is simply private to that
view.
class myClass
{
@view
{
private:
int x;
public:
void setX(int x) { this.x = x; }
int getX( return this.x; }
}
private:
void fred() { this.x = -1; } // error: fred is not part of
the view that contains x
int waldo() { return this.x; } // error: waldo is not part
of the view that contains x
public:
void foo() { this.x = -1; } // error: foo is not part of
the view that contains x
int bar() { return this.x; } // error: bar is not part of
the view that contains x
}
More information about the Digitalmars-d
mailing list