On Friday, 18 May 2018 at 12:16:55 UTC, aliak wrote:
On Friday, 18 May 2018 at 12:00:58 UTC, Gheorghe Gabriel wrote:
On Thursday, 17 May 2018 at 02:32:07 UTC, KingJoffrey wrote:
[...]
I think this code has cleaner sintax:
class A {
private int x;
sealed int y;
}
void main() {
A a = new A();
a.x = 7; // ok, it's private to module
a.y = 3; // error, it's sealed to class
}
You may not need a new word at all. You can also enhance
private to take arguments. Package already does this. You can
give private a symbol list that says which symbols this is
private for. So:
class A {
private int x;
private(A) int y;
}
void main() {
A a = new A();
a.x = 7; // ok, it's private to module
a.y = 3; // error, it's sealed to class
}
Cheers,
- Ali
Good idea. Or: private(this)
Because using "this" it is easier tu put this code in a mixin for
multiple classes.
Example:
string var = "private(this) var;";
class A {
mixin(var);
}
class B {
mixin(var);
}