Sealed classes - would you want them in D? (v2)

aliak something at something.com
Fri May 18 12:38:06 UTC 2018


On Friday, 18 May 2018 at 12:26:14 UTC, Gheorghe Gabriel wrote:
> 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);
> }

Me like :)

You can have both so you can do what you say with private(this) 
and also allow access from other classes/structs

class A { private(this, B) onlyForMeAndTypeB; }

Essentially a more fine grained version of C++'s friend.


More information about the Digitalmars-d mailing list